So I am a beginner to Python (previous experience with Java), and I was creating a simple OOP program. Here is my class:
from Tools.scripts.treesync import raw_input
class Info:
def startGame(self):
name = raw_input('What is your name?\n')
age = raw_input("What is your age?\n")
color = raw_input("What is your favorite color\n")
print("Your name is %s, your age is %s, and your favorite color is %s" % (name, age, color))
return Info
class App:
def build(self):
game_app = Info()
game_app.startGame()
return game
if __name__ == "__main__":
obj = App()
game = Info()
obj.build()
This is the output:
Your name is Chris
, your age is 18
, Sand your favorite color is Red
I am confused as to why it is printing on 3 lines? Is there any way to print this onto a single line?
Tools.scripts.treesync.raw_inputfunction and the standardlib raw_input (which should strip newline characters)?inputinstead ofraw_inputor usename.strip()to remove the trailing newline (also for the other variables)