1
How can I make a repeat loop while stopping when the user inserts a blank space (" ")?
I tried to do so:
while num != '':
num = int(input("Insira um número: "))
But the variable is not an integer, so when inserting a blank space, it presents an error.
When inserting the blank space, it continues and shows the result.
Empty space is somewhat dubious. Type a space character followed by a ENTER or just a ENTER? Maybe just convert to numeric string typed has length greater than zero and if it is not a space?
– anonimo
is for the user to keep typing for example: 1 3 5 and then when he does not type anything, just enter, show the final result
– Gustavo Carvalho
So it’s not for him to enter a space? In this case just check if the input is an empty string.
– anonimo
@Gustavocarvalho Did the answer solve your question? Do you think you can accept it? See [tour] if you don’t know how to do it. This would help a lot to indicate that the solution was useful to you. You can also vote on any question or answer you find useful on the entire site
– Maniero