Question
From the string sentence = 'we are never ever getting back together' , How can I code the uses list comprehension to reverse the words
From the string sentence = 'we are never ever getting back together' , How can I code the uses list comprehension to reverse the words in the string. How can I use the reversed() and join() functions. Albeit, this solution is just one line of code, this is a challenging problem. How can I break this down into multiple steps:
1) know how to split a string into a list of words.
2) Reverse the list of words using reversed(). The end result should the a list of the words in reverse order.
3) Use list comprehension to iterate through the list of reversed words.
4) Use join() to join the words in the reversed list into a string.
sentence= 'we are never ever getting back together'
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