Advertisement
dimkiriaoks

lowest-higest

Nov 10th, 2021
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.52 KB | None | 0 0
  1. def lowestHighest(students):
  2.     lowest = students[0]
  3.     highest = students[len(students)-1]
  4.     for i in range(len(students)):
  5.         if lowest > students[i]:
  6.             lowest = students[i]
  7.         if highest < students[i]:
  8.             highest  = students[i]
  9.         if highest < lowest:
  10.             highest, lowest = lowest, highest
  11.     return lowest, highest
  12.  
  13.  
  14. lowest = 0
  15. highest = 0
  16.  
  17. students = [10, 3, 6 , 7, 9, 5, 4]
  18. lowest, highest = lowestHighest(students)
  19. print(f"lowest: {lowest}, highest: {highest}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement