Using python 3, I need help coding this problem. (Not allowed to use break) Writ
ID: 3590680 • Letter: U
Question
Using python 3, I need help coding this problem. (Not allowed to use break)
Write a program that, within main(), asks the user for 1. The number of words they want to enter into the program 2. That amount of words (and stores them in a list) Once all of the words have been entered, the program must print them out in reverse order from how they were entered, and must also show what the word would be backwards. (See the sample output for an example.) The program must use a function called backwards(), that works as specified in the function header provided below. ###################################################### # backwards() reverses a string and prints the result # Input: forString, a string to reverse # Output: None
(Again, do not use any built-in function or “trick” that circumvents the point of this assignment, or you will earn zero points. If you’re not using a loop to create the backwards string, you’re doing it wrong.)
How many words would you like to turn backwards: 5 Please enter string #1: dog
Please enter string #2: bird
Please enter string #3: horse
Please enter string #4: fish
Please enter string #5: llama
The string 'llama' reversed is 'amall'.
The string 'fish' reversed is 'hsif'.
The string 'horse' reversed is 'esroh'.
The string 'bird' reversed is 'drib'.
The string 'dog' reversed is 'god'.
bash-4.1$ python hw5_part5.py
How many words would you like to turn backwards: 3
Please enter string #1: Kayak
Please enter string #2: Racecar
Please enter string #3: Stats
The string 'Stats' reversed is 'statS'.
The string 'Racecar' reversed is 'racecaR'. T
he string 'Kayak' reversed is 'kayaK'.
bash-4.1$ python hw5_part5.py
How many words would you like to turn backwards: 0
bash-4.1$ python hw5_part5.py
How many words would you like to turn backwards: 1
Please enter string #1: step on NO pets
The string 'step on NO pets' reversed is 'step ON no pets'.
Explanation / Answer
Hi,
Below is the code. Please make changes to code alignment and messages as per your need.
Python code-
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.