How TO Receive a List of String in Python?

2023/03/27 2:49

Write a Python3 program that receives a list of strings on standard input, one per line,

reverses each string, and prints them to standard output.

Here is a simple program that will receive a list of strings on standard input, reverse each

string, and print them to standard output:

while True:


line = inputQO

except EOFError:


printCline[: :-1])

To use this program, you can simply copy and paste the code into a file and run it with a

Python interpreter. For example, you could save the code to a file called

and run it like this:


You will then be able to enter strings, one per line, and the program will reverse each

string and print the result. When you are finished, you can press ~CTRL+D~ (on Linux or

macOS) or ~CTRL+Z* (on Windows) to indicate that there are no more strings to be

entered, and the program will exit.

Back to top