python - Output unformated? -
i newbie in python. doing exercise in learnpythonthehardway mr. zed shaw. have been stuck problem
here code:
age=input("how old you?"); height=input("how tall you?"); weight=input("how weight?"); print ("age = %r height = %r weight = %r" %(age,height,weight))
and output:
d:\python>python sample1.py how old you?22 how tall you?182 how weight?178 age = '22\r' height = '182\r' weight = '178\r'
i not understanding, how that, getting "\r" output? please !!!
it looks using python 3. in python 3, input()
function returns string typed @ prompt. in python 2, input()
function returns evaluated expression, in case if type number integer.
you have 3 basic choices:
- find tutorial uses python 3
- install python 2 use current tutorial
- simulate python 2
input()
usingeval(input(...))
Comments
Post a Comment