largest = None
smallest = None
while True:
try:
num = input("Enter a number: ")
if num == "done":
break
#print (num)
num = int(num)
if largest is None or largest < num:
largest = num
elif smallest is None or smallest > num:
smallest = num
except ValueError:
print("Invalid input")
print ("Maximum is", largest)
print ("Minimum is", smallest)
2 Comments
infinite loop me fas jayenge
ReplyDeletelargest = None
ReplyDeletesmallest = None
while True:
num = input("Enter a number: ")
if num == "done":
break
try:
n = int(num)
if largest is None or largest n:
smallest = n
elif smallest <n:
n = n
except:
print("Invalid input")
print("Maximum is", largest)
print("Minimum is" ,smallest)