Advertisement
OreganoHauch

Maximum function for all numbers in a list 2

Jan 12th, 2020
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. # MAXIMUM FUNCTION FOR ALL NUMBERS IN A LIST: WITH > COMPARISON
  2.  
  3. def maxvalue(list):
  4. # filters out only int and float from list:
  5. list_converted = []
  6. for j in range(len(list)):
  7. if type(list[j]) in (int, float):
  8. list_converted.append(list[j])
  9. maxvalue = list_converted[0]
  10. for i in range(len(list_converted)):
  11. if list_converted[i] > maxvalue:
  12. maxvalue = list_converted[i]
  13. print("Your list was:\n" + str(list_converted) + "\nIts maximum numeric value is " + str(maxvalue) + ".")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement