Why there is 3 lines in the output for this code? I want only 2 lines ? Pls help | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why there is 3 lines in the output for this code? I want only 2 lines ? Pls help

Print("what is your name""\n") X = input() Print("your name is " + (x)

5th Feb 2022, 9:46 AM
ZIZO Abd alkawy
6 Answers
+ 4
You usually don't need to add a new line at the end of a print statement since in python print statements include a new line at the end by default.
5th Feb 2022, 9:48 AM
Simon Sauter
Simon Sauter - avatar
+ 3
Yes. That's an empty line, right? Your first print statement adds a line break because you used a newline character. But it adds another line break because in python print statements already include a newline character "under the hood".
5th Feb 2022, 9:58 AM
Simon Sauter
Simon Sauter - avatar
+ 2
Simon Sauter I understood thanks I deleted the (\n) and it worked there is only 2 lines
5th Feb 2022, 10:19 AM
ZIZO Abd alkawy
0
The third line is in the middle Simon Sauter
5th Feb 2022, 9:55 AM
ZIZO Abd alkawy
0
Iam sorry but may explain the lesson 12 working with variables for me the second part from it because I didn't understand it Simon Sauter
5th Feb 2022, 10:29 AM
ZIZO Abd alkawy