● Create a new Python file in this folder called manipulation.py. ● Ask the user to enter a sentence. Save the user’s response in a variable called str_manip. ● Using this string value, write the code to do the following: ○ Calculate and display the length of str_manip. ○ Find the last letter in str_manip. Replace every occurence of this letter in str_manip with ‘@’. E.g. if str_manip = “This is a bunch of words”, the output would be “Thi@ i@ a bunch of word@” ○ Print the last 3 characters in str_manip backwards. E.g. if str_manip = “This is a bunch of words”, the output would be “sdr”. ○ Create a five-letter word that is made up of the first three characters and the last two characters in str_manip. E.g. if str_manip = “This is a bunch of words”, the output would be “Thids”. ○ Display each word on a new line.
● Create a new Python file in this folder called manipulation.py.
● Ask the user to enter a sentence. Save the user’s response in a variable
called str_manip.
● Using this string value, write the code to do the following:
○ Calculate and display the length of str_manip.
○ Find the last letter in str_manip. Replace every occurence of this
letter in str_manip with ‘@’. E.g. if str_manip = “This is a bunch of
words”, the output would be “Thi@ i@ a bunch of word@”
○ Print the last 3 characters in str_manip backwards. E.g. if str_manip
= “This is a bunch of words”, the output would be “sdr”.
○ Create a five-letter word that is made up of the first three characters
and the last two characters in str_manip. E.g. if str_manip = “This is a
bunch of words”, the output would be “Thids”.
○ Display each word on a new line.
Step by step
Solved in 2 steps with 2 images