If your intention is to capture multiple values from one input(), you can use one of the command lines listed below:
Example 1:
valores = list(map(int, input('Digite todos os valores: ).split()))
Example 2:
valores = [int(x) for in input('Digite todos os valores: ).split()]
Example 3:
a, b, c = [int(x) for in input('Digite todos os valores: ).split()]
Note that when we run each of the 3 examples listed above, we received the following message: Digite todos os valores:
. Right now we must type all the intended values, in same line, separated for a single space and press enter
.
In both examples, the values captured by input() are stored in a list.
In the first two examples we can type a quantity undefined of values, that is to say, how many values we want.
In the third example, we can only type the amount of whatever values equal to the number of variables that, perhaps, is the left side of the assignment signal - which in Pytho is represented by the =
. In this specific case, we will only be able to type 3 values.
Also, note that to use one of the three forms listed above, we need to identify the guy desired variable. In the examples cited above, I used only the whole type - int. However, we may use other types of variables. To do this, simply replace the type int, by the type desired.
You are reporting the numbers separated by space, but you are trying to divide the string with
""
, why? Do the.split(" ")
to separate in the blank.– Woss
Can also do
split()
without indicating the separator that the default separator is a space and will divide by words as you want.– Isac