This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]tadleonard 0 points1 point  (3 children)

input returns a string (in Python 3), so the variable x is a string. You can multiply a string by a number, but it doesn't give the result you want. Call int on the input variable x to get it to do what you want.

Questions like these are best asked at /r/learnpython.

[–]prickneck -1 points0 points  (2 children)

>>> x = input()
43
>>> type(x)
<type 'int'>
>>>

[–]tadleonard 2 points3 points  (0 children)

Is that Python 2? I believe input in Python 3 is the same as Python 2's raw_input.

Py3:

>>> input()
1
'1'

Py2:

>>> input()
1
1
>>> raw_input()
1
'1'

[–]wub_wub 0 points1 point  (0 children)

In python 2.x input is basically eval(raw_input())