1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | """ Program Name: Largest and Smallest Description: Check for largest and smallest number """ while True : num = input("Enter numbers with space : ").split() valid = True for x in num : if not x.replace("-", "").isdigit() : valid = False break if valid : break else : print("All inputs should be numbers") big = small = int(num[0]) for x in num : x = int(x) if x < small : small = x if x > big : big = x print(f"\n{big} is the largest number") print(f"{small} is the smallest number") |