Write a program that takes in a line of text as input, and outputs that line of text in reverse. The program repeats, en

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Write a program that takes in a line of text as input, and outputs that line of text in reverse. The program repeats, en

Post by answerhappygod »

Write a program that takes in a line of text as input, andoutputs that line of text in reverse. The program repeats, endingwhen the user enters "Done", "done", or "d" for the line oftext.
Ex: If the input is: Hello there
Hey
done
then the output is:
ereht olleH
yeH
Additional tips:
• Use nested loops
• The outside while loop deal with the strings "Done", "done",or "d"
• The inside for loop will iterate through character bycharacter for any other string
• Incorporate the range() function into your for loop to gobackwards character by character
• The starting value of your range should be len()-1
• Build your output string by concatenating the next letter witheach iteration of the for loop
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply