# Chapter 9 Exercise 2: Sorted Names # This program allows the user to enter 20 names and then sorts them in alphabetical order # Written by Beth Mela # Last updated May 11th, 2015 # Define the list and constants userEnteredNames=[] numberOfNames=20 # Get input and generate the list for i in range (1,numberOfNames+1): name=raw_input('Please enter a name: \n') userEnteredNames.append(name) # Sort the list userEnteredNames.sort() # Print results print('The names entered in alphabetical order are: {}.'.format(userEnteredNames))
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question