Hello,
I been watching videos from python for everyone and there was this code.
Thanks for help.
Raivis.
I been watching videos from python for everyone and there was this code.
numlist = list() while True: inp = input("Enter a number:") if inp == 'done' : break value = float(inp) numlist.append(value) avarage=sum(numlist) / len(numlist) print('Avarage: ', avarage)It runs fine for while and then it would give this error at some points when entering new number:
Error:Traceback (most recent call last):
File "c:\Users\...\Desktop\PYton\numlist.py", line 5, in <module>
value = float(inp)
^^^^^^^^^^
ValueError: could not convert string to float: ''
Just wondering why that happens.Thanks for help.
Raivis.
buran write May-19-2023, 08:18 AM:
Please, use proper tags when post code, traceback, output, etc. This time I have added
See BBcode help for more info.
Please, use proper tags when post code, traceback, output, etc. This time I have added
error
tags for you.See BBcode help for more info.