Skip to content
← Back to Community
How do I print multiline strings side-by-side?
Profile icon
Brendan23

so if you type in more than one a when you run the repl, it will print one a and another below it. is there a way to get them side-by-side?

Voters
Profile icon
Brendan23
Comments
hotnewtop
Profile icon
IOP3

use sys.stdout.write("whatever")

Profile icon
Brendan23
Profile icon
IOP3

@Brendan23 did it work?

Profile icon
Brendan23

@IcingHackz hmm... doesn't work. is this what I was supposed to do?:

sys.stdout.write(bold)
Profile icon
Brendan23
Profile icon
IOP3

@Brendan23 yeah, that's what you're supposeed to do. It looks fine to me

Profile icon
Brendan23

@IcingHackz did you run it? it still prints one on top of each other. thats not what I want.

Profile icon
IOP3

@Brendan23 hmm. lemme think

Profile icon
Brendan23

@IcingHackz ok. you can think.

Profile icon
Coder100

not to mention it also aligns the text beautifully! (Probably)

https://repl.it/@Coder100/WryImaginaryConfiguration-eouae-ou-eoaueao-ue#main.py

yay!

Profile icon
Coder100

Nope, you can't do this simply with yourself.

Try dis:

def side_by_side(*args): print('\t'.join(args))

And also:

side_by_side("hi", "there")

you might be thinking bruh isn't this the most obvious thing
and you are correct, that is what you have to do in something as limited as a terminal.

Profile icon
Brendan23

@Coder100 hmm.. doesn't work. :(

Profile icon
Brendan23

@Brendan23 I think its because its multi-line text.

Profile icon
Coder100

well yeah
you can't have multiline text side by side @Brendan23

Profile icon
Coder100

just split it into two function calls, one for the first line, and another for the second one. @Brendan23

Profile icon
Brendan23

@Coder100 oh yeah. right. I should have thought of that.

Profile icon
Brendan23

@LeoXu2 @RYANTADIPARTHI so. what I want to do is print more than one multi-line letters next to each other. make sense? for example, if you run the repl and type in multiple a's then it will print one on top of another. I don't want that. I want it side by side.

Profile icon
LeoXu2

you could also use \n i think. so if you need a new line, you can just use: print("ayo\nthis is a new line")

Profile icon
LeoXu2

@LeoXu2 pls mark as correct if i helped

Profile icon
Brendan23

@LeoXu2 thats not what I want to do. I want to put both of the letters side by side. not on a new line.

Profile icon
LeoXu2

@Brendan23 you could use replit.clear() to clear the console and keep rewriting the letters every time a new one is inputted. 🤔

Profile icon
LeoXu2
Profile icon
RYANTADIPARTHI

could you explain clearly?