Computer Science, asked by midhunamurali2019, 7 months ago

WAP that accepts a hyphen ( -) separated sequence of words as input and prints the words in a hyphen ( -) separated sequence after sorting them alphabetically.
FOR EXAMPLE :
input: green-red-yellow-black-white result: black-green-red-white-yellow

Answers

Answered by thisyanth
0

toolsGoogle Docs Forms TemplatesGoogle Docs Slide PresentationsNumber ConversionsLinux TutorialsQuizzesArticles

Python Exercise: Accept a hyphen-separated sequence of words as input and prints the sorted words

Last update on February 26 2020 08:09:18 (UTC/GMT +8 hours)

Python Functions: Exercise-15 with Solution

Write a Python program that accepts a hyphen-separated sequence of words as input and prints the words in a hyphen-separated sequence after sorting them alphabetically.

Sample Solution:-

Python Code:

items=[n for n in input().split('-')] items.sort() print('-'.join(items))

Copy

Sample Output:

green-red-black-white black-green-red-white

Pictorial presentation:

Flowchart:

Similar questions