From the course: Level Up: Python
Unlock the full course today
Join today to access over 24,900 courses taught by industry experts.
Sort a string - Python Tutorial
From the course: Level Up: Python
Sort a string
(upbeat music) - Manipulating strings and sorting things are common tasks in everyday programming. So this challenge will give you practice doing just that. Your goal is to write a Python function to sort the words in a string. It should accept a string containing one or more words separated by spaces as the input argument, and then return a string containing those words sorted alphabetically. A call to the function might look like this, taking in a string of words and then returning the string of string words. You should ignore the case of the words when sorting them. However, the output should have the same upper and lowercase letters as the corresponding input words. For example, the input string 'banana ORANGE apple' should produce the output shown here with 'apple banana ORANGE.' Notice that even though the word orange was capitalized it was still sorted to the end of the output string because that's where it belongs…
Contents
-
-
-
Find prime factors3m 11s
-
(Locked)
Identify a palindrome2m 48s
-
(Locked)
Sort a string3m 2s
-
(Locked)
Find all list items3m 12s
-
(Locked)
Play the waiting game2m 22s
-
(Locked)
Save a dictionary3m 13s
-
(Locked)
Schedule a function3m 16s
-
(Locked)
Send an email3m 12s
-
(Locked)
Simulate dice3m 16s
-
(Locked)
Count unique words3m 12s
-
(Locked)
Generate a password3m 59s
-
(Locked)
Merge CSV files3m 35s
-
(Locked)
Solve a sudoku4m 8s
-
(Locked)
Build a zip archive3m 42s
-
(Locked)
Download sequential files4m 2s
-