+ 1
How to use input function as a integer in Python.
3 Respostas
+ 5
If you want to input more than 1 value, it can be done like this. The values from input will be integer and are stored in a list:
You can use an input with split, map and int conversion or a list comprehension with int conversion:
(1) input with split(), int conversion:
inp = list(map(int, input('').split())) # input like: 1 3 12
(2) input with split(), int conversion and comprehension:
inp = [ int(i) for i in input().split()] # input like: 1 3 12
Both versions have the result of: [1,3,12]
+ 4
Number = int(input())
And everything remains the same.. you can also give the prompt message inside the input function
+ 2
Var1 = int(input())