Edit: Here are the test values (7, 2, bob, 10, and 4) and desired output
Invalid input Maximum is 10 Minimum is 2 for people who want them :)
Hello! So I got this problem where I have to take input from user and then when the type done the largest and smallest values come out. There was a small part where if you put wrong data it will tell you that but I got that "done" perfectly. But the part where I have to decide as largest and smallest is my issue. I setup Nonetype for each of the values but when i put it in the if statements it simply selects the first input as largest. I have attached my code below. Any modification could be of help. Thank you.
Largest = None
Smallest = None
while True :
num = input("Enter a number: ")
if num == "done" :
break
try :
fnum = int(num)
except :
print("Invalid input")
continue
if Largest is None:
Largest = fnum
elif Smallest is None:
Smallest = fnum
elif fnum > Largest:
fnum = Largest
elif fnum < Smallest:
fnum = Smallest
print("Maximum is",Largest)
print("Minimum is",Smallest)