maynul67

find the largest number from user inputs

Aug 10th, 2021
894
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. print("Get the largest number \nTo quit enter 'q'\n-------------------------------------")
  2. def get_larger():
  3.     list1 =[]  
  4.     while True:
  5.             inp = input("enter number : ")
  6.             if inp == "q":
  7.                 break
  8.             try:
  9.                 n = float(inp)
  10.                 list1.append(n)
  11.             except ValueError:
  12.                 print("invalid input")
  13.     return max(list1)
  14.    
  15. largest = get_larger()
  16. print(f"The largest number is {largest}")
RAW Paste Data