I've been banging my head against the wall with this task and I can't seem to figure it out for the life of me.
I want to write a script that would prompt a user to input a number and store that number in a list every time after they input the number. When the user would just press enter and not input anything, the script would then print out the highest number in the list.
This is what I wrote so far:
x = 0
mylist = []
while x != '':
x = input("enter a number:")
mylist.append(x)
if x == '':
print(max(mylist))
There are two problems with this code that I can see:
The user can input a string (I tried fixing that by saying x = int(input(...), but that only lead to a new error:
ValueError: invalid literal for int() with base 10: ''
print(max(mylist)) only prints out the number with the largest initial integer. For instance, if the user inputs 51 and 112, it would print out 51.
Thank you for taking your time in helping me out.