Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
A program asks two questions.
The Input box has these two lines: India and then Pune. What does the program show? How must the Input box be written to get Pune is in India?
Have you tried it?
Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, go through the solution one step at a time, and check each step against your own.
Plan. Each input() reads the next line of the Input box. The first input() reads line 1, and the second reads line 2.
Step 1. The first line of the Input box is India, so town becomes India.
Step 2. The second line is Pune, so country becomes Pune.
Step 3. The program shows India is in Pune. This is wrong for the facts, but the program did what the Input box said.
Fix. Type the lines in the order of the questions: Pune on line 1 and India on line 2.
Check. Then town is Pune and country is India, and the output is Pune is in India.
Answer: The program shows India is in Pune. Write Pune first and India second.
Log in to join the discussion.
Loading…