DEV Community

Discussion on: Python print() and beyond

Collapse
 
josiasaurel profile image
Josias Aurel • Edited

In this case, I wanted every line to end with a y character rather than a y character on a newline.
Anyways, playing around with those will help grasp it better.

Collapse
 
ntchambers profile image
Nicholas Chambers • Edited

Yes, that's my point. Your code currently does not end every line with a y.

~ 🌲 python3
Python 3.9.0 (default, Nov 30 2020, 15:21:09)
[Clang 12.0.0 (clang-1200.0.32.27)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> print("Hello James", end="y\n")
Hello Jamesy
>>> print("How are you doing", end="\n")
How are you doing
Enter fullscreen mode Exit fullscreen mode

Your end for the second print is just \n. It is missing a y in it.

Thread Thread
 
josiasaurel profile image
Josias Aurel

You'll have to include the end="y" un every print statement . In the second print statement you wrote, you didn't include the end="y" and that's why you didn't get the y at the end of it.

Thread Thread
 
ntchambers profile image
Nicholas Chambers

I'm aware. This is your code, not mine. Your code does not currently include end="y\n" for the second line, just end="\n". However, you then show output with every line ending in a y: i.imgur.com/haIqpYx.png

Thread Thread
 
josiasaurel profile image
Josias Aurel

Oh thanks 🤦 I hadn't notice it . I'm really sorry for this

Thread Thread
 
ntchambers profile image
Nicholas Chambers

No problem! Happy to help!