+ 1
How to get an integer input?
Im new at python, and have written a simple code that multiplies the input with 2. I did take an x variable wich is = input('enter a number') Then y = x * 2, then print (y). I have tried to cgange it in many ways, but i can never get an intwger input
2 Respostas
+ 1
This might help :
x = int (input ("Enter a number "))
y = x * 2
print (y)
Python doesn't evaluate and convert the data type, you have to explicitly convert to int
- 1
Then the output is (when for example enter 4 in input): enter a number8. How to get simple an 8?