Question
Create a function called alphabetical(sentence) that takes in a sentence as a string and returns a list of the words in the sentence in alphabetical
Create a function called alphabetical(sentence) that takes in a sentence as a string and returns a list of the words in the sentence in alphabetical order. Hint #1: Use string methods to convert the sentence into a list, and list methods to properly order the list! Hint #2: Remember that uppercase letters are alphabetically before lowercase, as shown in the examples below. You dont need to worry about correcting this. Examples: alphabetical(Welcome to CSC111!) returns [CSC111!, Welcome, to] alphabetical(Do your homework) returns [Do, homework, your] alphabetical(Python: more than a snake) returns [Python:, a, more, snake, than] When you are confident everything in your script is working correctly, submit your homework7.py file below.
Coding Practice Create a new python script called homework7.py. You will define the following function in your script. Once you've run your script and ensured that it is correct, upload the script to the submission box below. Be sure to document your function as described in lab slides 3 and fill out the top portion of the template, including the Worklog and Acknowledgements sections. Create a function called alphabetical(sentence) that takes in a sentence as a string and returns a list of the words in the sentence in alphabetical order. Hint #1: Use string methods to convert the sentence into a list, and list methods to properly order the list! Hint #2: Remember that uppercase letters are alphabetically before lowercase, as shown in the examples below. You don't need to worry about correcting this. Examples: alphabetical("Welcome to CSC111!") returns ["CSC111!" "Welcome" "to"] alphabetical(Do your homework") returns ["Do", "homework your] alphabetical("Python: more than a snake") returns [Python:", "a", "more","snake" "than"] When you are confident everything in your script is working correctly, submit your homework7.py file below
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started