PYTHON   48
normalize numbers
Guest on 26th August 2023 12:33:52 AM


  1. def normalize(numbers):
  2.     max_number = max(numbers)
  3.     for i in range(len(numbers)):
  4.         numbers[i] /= float(max_number)
  5.     return numbers
  6.  
  7. try:
  8.       normalize([0, 0, 0])
  9. except ZeroDivisionError:
  10.       print('Invalid maximum element')

Raw Paste

Login or Register to edit or fork this paste. It's free.