Ria is a 5 year old girl. Her mother wants to teach her how to sort words in the same…
- User
Ria is a 5 year old girl. Her mother wants to teach her how to sort words in the same order that they appear in a dictionary. She decides to write a program to sort a given set of strings based on their alphabetical order. Help Ria’s mother to complete the program.
Input Description: A set of N strings
Output Description: Alphabetically sorted set of strings
Sample Input : 3 InfinityWar EndGame Avengers Sample Output : Avengers EndGame InfinityWar
Assistant
Here is a Python program to sort the strings in alphabetical order:
pythonn = int(input()) # Number of strings words = [] # Read all strings and store in a list for i in range(n): words.append(input()) # Sort the list of strings in alphabetical order words.sort() # Print the sorted strings for word in words: print(word)
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.