Advertisement
Guest User

Untitled

a guest
Apr 25th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.81 KB | None | 0 0
  1. #pre-define the number of presidents to request the user to input in the range
  2. number_of_additional_presidents = 4
  3. presidents = ["Clinton", "Bush", "Obama", "Trump"]
  4. def main():
  5.     #initiate the assignment with a list of our 4 most recent presidents
  6.  
  7. #request user to insert the name of 4 additional presidents to be added to our table
  8.     for yourpresidents in range(number_of_additional_presidents):
  9.         s = (input('Enter the name of another president '))
  10.         presidents.append(s)
  11.  
  12.  
  13. #for aesthetic reasons, line breaker, aswell as a title
  14.     print()
  15.     print("Here is your list of presidents, sorted:")
  16.     print()
  17.  
  18. #sort your list of presidents and print
  19. def printPresidents():
  20.     presidents.sort()
  21.     for i in range(len(presidents)):
  22.         print(presidents[i])
  23.  
  24. main()
  25. printPresidents()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement