Mar-18-2019, 10:25 AM
(Mar-18-2019, 08:25 AM)Yoriz Wrote: A single quote is ok when wrapped inside double quotes.
Not always true, get a glance underneath.
# ------- input-output.py ----------- friendName = input("Hey bud. What's your name?") eyeColor = input("What color are your eyes, " + friendName) hairColor = input("What color is your hair?") friendAge = input("Awesome! Mine too. How old are you?") # Let's see when this chap was born... int_friendAge = int(friendAge) int_yearBorn = 2019 - (int_friendAge) yearBorn = str(int_yearBorn) print("That means you were born in " + yearBorn) # ---------- Running under python2 [ERROR]---------- #C:\Training>py -2.7 input-output.py #Hey bud. What's your name?bill #Traceback (most recent call last): # File "input-output.py", line 2, in <module> # friendName = input("Hey bud. What's your name?") # File "<string>", line 1, in <module> #NameError: name 'bill' is not defined # # ---------- Running under python3 [WORKS]---------- #C:\Training>python input-output.py #Hey bud. What's your name?bill #What color are your eyes, billblue #What color is your hair?black #Awesome! Mine too. How old are you?15 #That means you were born in 2004 #------------------------------------------------------