Sorting by alphabet
Write a program that receives a number of names from the input and then arranges them based on alphabetic letters and prints in the output
Write a program that receives a number of names from the input and then arranges them based on alphabetic letters and prints in the output
let msg = 'error' alert(msg)This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error' alert(msg)This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error' alert(msg)This answer is only visible to premium members
This answer is only visible to premium members
names = [] # List for names while True: # As long as name_user = input('please enter your names: ') # Get input from the user if name_user == '': break else: names.append(name_user) names.sort() print(names)
names_list = [] for i in range (10): names_list.append(input('Enter name : ')) names_list.sort() print(names_list)
names = [] while True: user_input = input("Please enter a name: (enter to exit)") if user_input == "": break else: names.append(user_input) names.sort() print(f"Sorted name => {names}")
names=[] while True: name = input("inter your names: ") if name.lower() == 'end': break names.append(name) print(sorted(names))
# Get names and sorting by alphabet x = input('please enter name with - seprator:') x = x.lower() # Sorting to size and small letters are sensitive x= x.split('-') x.sort() # Make sure you do not push the sorting command into the variable for item in x: print(item)
asami = [] while 1: names = input("please enter a name: ") if names == 0: break elif names.isalpha(): asami.append(names) else: print(sorted(asami))
Names = []
while True :
name = input("enter the name : ")
if name == "0":
break
Names.append(name)
Names.sort()
print(Names)
Submitting answers is currently unavailable.
You must be logged in to access this section.
Login/Sign up If you don’t understand the exercise or can’t solve it for any reason, that’s completely
normal—don’t worry 😊
Try checking out easier exercises and reviewing different answers
submitted by others. Gradually, you can move on to more challenging exercises. Also, your answer
might be correct even if it’s different from others.