write a phython program to input tow integers number and print smallest number
Answers
Answered by
1
Answer:
I am trying to write a program that repeatedly prompts a user for integer numbers until the user enters 'done'. Once 'done' is entered, print out the largest and smallest of the numbers. If the user enters anything other than a valid number catch it with a try/except and put out an appropriate message and ignore the number.
Example ♻️ I am having problem in printing the largest and smallest number. Its printing incorrect number by the approach below:⚠️
SOME PROGRAMS I GIVE YOU
largest = None smallest = None list1 = [] while True: num = input("Enter a number: ") if num == "done" : break try: val = int(num) if int(num): list1.append(num) except: print("Invalid input") print("Maximum is " + max(list1)) print("Minimum is " + min(list1))
Similar questions