+ 1
Help me to solve this problem
Write a Python program that reads input from the keyboard (standard input). The input will consist of an even number of lines of text. The input will be terminated by a blank line. Suppose there are 2n lines of input. Your program should print out the last n lines of the input, i.e., the second half of the input, followed by the first n lines, i.e., the first half of the input. E.g., if the input is the following: our dear friend, let's eat then the output should be: let's eat our dear friend,
2 Answers
+ 10
I would create an infinite loop asking the user for an input() each time. Then I would check if the input is empty and if so, terminate the program. But if not - the input should be added (appended) to a list.
Then, when you have the list filled with input lines and the user enters an empty string, print all lines from the half of the list's length till the end and then from its beginning to half its length.
Tadaam! :)
0
Thanks @Kuba