A first step would be to get the scores and call the split
method to get a list where each element is one of the scores:
pontuacoes = input("Digite as pontuações: ").split()
Then we have to transform those scores that are currently strings into integers. We can do this with a list understanding:
pontuacoes_int = [int(p) for p in pontuacoes]
Now, pontuacoes_int
is a list with the scores as integer values. If we want to assign these values to separate variables, we can do
a, b, c = pontuacoes_int
Another way to do this without list comprehension might look like this:
pontuacoes = input("Digite as pontuações: ").split()
a, b, c = int(pontuacoes[0]), int(pontuacoes[1]), int(pontuacoes[2])
This method also works, but it is interesting to learn how to use list comprehensions (or map
) because then your code works regardless of the number of elements that need to be transformed into integers.