Advertisement
codyzc

coding101_list_exercise

Apr 27th, 2014
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.85 KB | None | 0 0
  1. # Coding101 project April 2014
  2. # Cody Climer
  3. # With this program you give it a list of Cities
  4. # The program will then arrange them alphabetically
  5.  
  6. cityList = []
  7.  
  8. # Input loop
  9. while True:
  10.   cityName = raw_input("Enter the name of a city (Otherwise just hit Enter): ")
  11.   if cityName == "":
  12.     break # Ends city name Entry
  13.   else:
  14.     cityList.append(cityName) # takes the entered name and adds it to the list
  15. # /Input loop
  16.  
  17. # Manipulate Data  
  18. print "Now we'll organize the Cities you've entered."
  19. print # I like having some breathing room when reading CLI output
  20.  
  21. cityList.sort() # Takes the entered cities and organizes them alphabetically
  22. # /Manipulate Data
  23.  
  24. # Print Loop
  25. for cityName in (cityList):
  26.   print str(cityName) #This takes the now organized list of cities and prints one per line
  27. # /Print Loop
  28.  
  29. print
  30. raw_input("Hit Enter to Exit")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement