0% found this document useful (1 vote)
4K views1 page

4.17 LAB Print String in Reverse

This document provides instructions and an example for a program that reverses strings. The program takes a line of text as input, prints it in reverse order, and repeats until the user enters "Quit", "quit", or "q". It uses a while loop to continually take string input, checks for a quit condition, and prints the reversed input string.

Uploaded by

CHRIS D
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
4K views1 page

4.17 LAB Print String in Reverse

This document provides instructions and an example for a program that reverses strings. The program takes a line of text as input, prints it in reverse order, and repeats until the user enters "Quit", "quit", or "q". It uses a while loop to continually take string input, checks for a quit condition, and prints the reversed input string.

Uploaded by

CHRIS D
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

4.

17 LAB: Print string in reverse


Write a program that takes in a line of text as input, and outputs that line of text in reverse.
The program repeats, ending when the user enters "Quit", "quit", or "q" for the line of text.
Ex: If the input is:
Hello there
Hey
quit
then the output is:
ereht olleH
yeH

while True:

values = str(input())

if values == 'quit' or values == 'Quit' or values == 'q':

break

print(values[::-1])

You might also like