#๐ how do i rearrange a printed message
32 messages ยท Page 1 of 1 (latest)
@glacial dome
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Please react with โ
to upload your file(s) to our paste bin, which is more accessible for some users.
that would be pretty difficult but you'd have to print its composite sections with the title
!e
oops
i tried but it did not work
i just a lot of error messages
what did you try?
i tried printing both of variables
!e ```py
s1 = """hello
hi
wow"""
s2 = """this
is
awesome"""
l1 = s1.split('\n')
l2 = s2.split('\n')
assert len(l1) == len(l2)
for i in range(len(l1)):
print(f"{l1[i]: <15}{l2[i]}")
oops
what ๐
:white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | hello this
002 | hi is
003 | wow awesome
there we go
we have two strings: yml hello hi wow ```yml
this
is
awesome
then we get their lines and print them with some padding between them
: <15 just makes it so that it adds spaces to the end of the string until the total length is 15
ok but can u tell me how i do that to my code?
cuz i got no idea lol
i am still kinda new to python
whatever your title is, chop that into lines with str.split
that's it?
so i type that before printing it?
then take your table, turn that into a string (might be harder) and then split that into lines too
then you can zip the two together like this: ```py
l1: list[str] = ...
l2: list[str] = ...
for a, b in zip(l1, l2):
print(f"{a: <15}{b}")
`a` is the line from `l1` and `b` is the line from `l2`
are u sure it won't mess up the print like add lines between the banner?
why would it?
idk terminal displays text weird sometimes
depends on how wide your terminal is
This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.