I am trying to make an input integer on a new line using python, but I get an error when I do this.
#inputs myMath as an integer
print = ("Give me a number and I will double it for you.")
myMath = int(input + "\n")
#Multiplies myMath(the variable) times 2
result = eval("2 * myMath")
The error says "TypeError: unsupported operand type(s) for +: 'builtin_function_or_method' and 'str'" I am using python 3.5.1.
答案 0 :(得分:1)
Here is what you want:
yourVal = int(input("Double a number:\n"))
result = yourVal*2
print(result)