#๐ exercise on website ".join(a + b)"
47 messages ยท Page 1 of 1 (latest)
@abstract lark
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.
i need to get Hello World as output but for some reason its adding spaces between the letters
and thats why i put a space in "here".join
a + b creates a new string "HelloWorld" and " ".join("HelloWorld") will make it so that " " appears in between each element of "HelloWorld".
hence, it prints out all the letters iwth a space in between
why is the .join method adding a space in between every letter then?
.join basically means "take every iterable element in this input, and put it together with the thing inbetween"
because you gave it a space
!e
print('TEST'.join("HelloWorld"))
:white_check_mark: Your 3.12 eval job has completed with return code 0.
HTESTeTESTlTESTlTESToTESTWTESToTESTrTESTlTESTd
well give it an iterable that will give the whole string
(aka a list)
a + โ โ + b
u mean like
' '.join([a] + [b])
no
#1298729335032905790 Anyone can help me? (Srry)
that creates a list with a single element "HelloWorld"
there's a bunch of different ways,
a + " " + b" ".join((a, b))f"{a} {b}"
aa i see
bro ๐ญ
wait for sm1 to help then
Ok
dont beg in other channels
Ok, sorry
only focusing on .join tho
yeah so pre much jus give it an iterable that has the elements you want
[a, b] works
or [a] + [b]
alright
yeye i understand
sounds goog
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, 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.
np