# File: ChapterLists/names.py """ How many names do you want to enter? 3 1. Enter name? aa 2. Enter name? bb 3. Enter name? cc List is ['aa', 'bb', 'cc'] 0 aa 1 bb 2 cc aa bb cc """ def main(): # create an empty list L = [] # ask the user for the number of names n = int(input( "How many names do you want to enter? " )) # get n strings from user and append them to the sequence for i in range( n ): name = input( str(i+1)+ ". Enter name? ") L.append( name ) L.sort() # sort them print("List is ", L) # print the contents of the sequence, one element at a time for i in range( n ): print(i, L[i]) for w in L: #better you do not need the length of the list! print(w,"\t",end="") main()