Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In PYTHON, write a program named program71.py that starts by making an empty lis

ID: 3696518 • Letter: I

Question

In PYTHON, write a program named program71.py that starts by making an empty list. Then the program must use a loop to prompt the user for the names of some notable celebrities and add each one to the list. Your loop must not predetermine how many celebrities will be added to the list. Instead, the loop should stop when the user enters "done" (NOTE: done must not be added to the list). The program should then output the number of celebrities entered. Next, the list should be sorted alphabetically. Finally, the program should use another loop to display the sorted celebrity names, each on its own line.

Explanation / Answer

# python code to input celebrities and sort the list

# empty list
list = []

celebrities = " "

# input celebrities name and add them to list
while 1:
celebrities = raw_input("Input names of notable celebrities: ")
if celebrities == "done":
break
else:
list.append(celebrities)

# output the number of celebrities entered
print " number of celebrities entered:", len(list)

# sort list in alphabetical order
list.sort()

# display sorted celebrities name
print " Sorted celebrities name"
for elements in list:
print elements

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote