hello, I got an exercise to request input from the member, untill he write empty string.
I tried to use this code:
while data != "":
but this I got this error, when I just enter without writin value:
ValueError: invalid literal for int() with base 10: ''
an empty string can’t be converted to integer. So you need to break this down into steps:
- get the input
- see if the input can be converted to integer
- convert the input to integer
or according to python idom: it’s easier to ask for forgiveness than permission, so step 2 could be trying to convert the input and handle the exception.