HELP I WILL MARK BRAINLIEST!!! I NEED ASAP!!!
Python: With a program to store the list of all your friends, then sort the list and print them in alphabetical order. The program should create a loop to accept the names of all your friends. Exit the loop when the user has no more items to input. Then sort the list alphabetically and print out the new list. (Side Note: Make Sure Your Code Works Before Submitting) Note: You cannot predefine the list of friends. The list should be initialized to an empty list

Respuesta :

#This is a way without a loop

friends = list(map(str,input("Enter Names: ").split()))

print(sorted(friends))

#This is a way with a loop (for&&while)

friends = list(map(str,input("Enter Names: ").split()))

cool = True

while cool:

   cool = False

   for i in range(len(friends)-1):

       if friends[i] > friends[i+1]:

           coo = friends[i]

           friends[i] = friends[i+1]

           friends[i+1] = coo

           cool = True

print(friends)

ACCESS MORE