Click here to Skip to main content
15,889,867 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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,

What I have tried:

i = 1
while 1:
line = input()
if line=='':
Posted
Updated 16-Sep-17 19:23pm

1 solution

Read your homework question again.
You need to read in lines of text, and store them until you get the blank line to end the input.
After that, you need to have two loops to print that output back: first print the last N / 2 lines, then print the first N / 2 lines.

This isn't complicated if you think about it for a little, and try to do it in stages: get the input part working first, then start working on the output.
But it's your homework, so I'll give you no code!
 
Share this answer
 
Comments
Member 13413688 17-Sep-17 1:58am    
its not homework its actually important questions given for our exam. and our teacher is on leave. so please help me
OriginalGriff 17-Sep-17 2:27am    
Exams are even more homework than normal homework!
You realise that trying to get exam questions answered is
A) Cheating. And the type of cheating which gets you an automatic fail, and makes all your other results look dubious?
B) Highly likely to be caught? Your tutors will be well aware of sites like this...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900