15,557,965 members
See more:
I want to sort every words in the sentence like this.

Enter the phrase: i love programming
Output: i elov aggimmnoprr

What I have tried:

```word = str(input("Enter the phrase: "))
print(''.join(sorted(word)))```
Posted
Updated 19-Oct-21 9:34am

## Solution 2

Marvin Añasco 21-Oct-21 2:15am
ty man?
Maciej Los 21-Oct-21 3:26am
If "ty man" means: "Thank you, man" then: you're very welcome.

## Solution 1

First, break the sentence into words: find all the separators (comma, full stop, space, and so forth) and use them to extract each word. Hint (if allowed by your teacher): what does the `split` function do?

Then, sort the collection of words. Hint (if allowed by your teacher): what does the `sort` function do?

Then join them back together with spaces, and print them.

But this is homework, so you'll get no code!

Marvin Añasco 19-Oct-21 5:27am
ty man but i'm done with this
Nelek 19-Oct-21 9:54am
Does it mean that you managed to solve it in 15 minutes?
If yes... why don't you try it on your own before posting a question online?
Marvin Añasco 21-Oct-21 2:14am
ur too late, i'll already have code with this, but my problem is code, u can see my code above.
Marvin Añasco 19-Oct-21 5:30am
i split the words by loop then after separate the words i use sorted() function for every words after that i use (end=' ') to print the same line

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Top Experts
Last 24hrsThis month
 Richard Deeming 90 Graeme_Grant 80 CHill60 60 Richard MacCutchan 44 Afzaal Ahmad Zeeshan 35
 OriginalGriff 3,944 Graeme_Grant 1,757 Richard MacCutchan 1,530 CPallini 802 Dave Kreskowiak 780

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900