print('Input a list of numbers to do statistics on them. Type stop to end the list.')
while True:
number_list = []
stop_input = False
while stop_input == False:
user_input = input('-> ')
if float(user_input):
number_list.append(user_input)
elif user_input == 'stop':
stop_input = True
print('Sum:', sum(number_list))
The error is as follows:
if float(user_input):
ValueError: could not convert string to float: 'stop' (line 10).
I am typing input in as
1.0
2.0
3.0
stop
if not stop_inputinstead ofif stop_input == False. Moreover, your error comes from your input: if you try to enter letters, the function to convert your input to float (a decimal number) will fail. So you need to either catch the exception, or change your logic.float("Not a float literal")will raise an exception, not returnFalse. You'll have to catch it.