I am struggling with my code - can sb help ? why it does not print "Invalid input" when i run it in Python and enter something else than the integer ?
Basically the program should run in endless loop until we enter "done". so even after except it should still prompt for entering a number.
largest = None
smallest = None
while True:
num = raw_input("Enter a number: ")
try:
if num == "done" :
print "Maximum is", largest
print "Minimum is", smallest
exit
if largest is None:
largest = num
elif largest < num:
largest = num
if smallest is None:
smallest = num
elif smallest > num:
smallest = num
except int(num) == -1:
print "Invalid input"
continue
int(num)on it.