I am new to programming and I am writing a program to find the smallest and largest number in inputs made by the user.
The user enters numbers one at a time and ends by entering "done". If the user enters a non-numeric input other than "done", an error message should be displayed.
When I run my code, it appears that the word "done" which is supposed to be the one that terminates the code seems to be the input the computation is performed on.
How can I let the program accept inputs and only execute the computation on integer variables without string variables?
Below is my code:
largest = None
smallest = None
while True:
num = input("Enter a number: ")
if num == "done":
break
for value in num:
try:
imp = int(num)
except:
print ("Invalid input")
continue
smallest = min(num)
largest = max(num)
print("Maximum is: ", largest)
print("Minimum is: ", smallest)