I'm trying to understand splat-operators in python. I have a code:
word = ['s', 't', 'a', 'c', 'k', 'o', 'v', 'e', 'r', 'f', 'l', 'o', 'w']
print(*word)
output:
s t a c k o v e r f l o w
I can't assign *word
to some variable to check its type or smth else in debug. So I wounder which way print()
gets the sequence of *word
and if it's possible to print this word without spaces. Desirable output:
stackoverflow
You get that result because print
automatically puts spaces between the passed arguments. You need to modify the sep
parameter to prevent the sep
aration spaces from being inserted:
print(*word, sep="") # No implicit separation space
stackoverflow
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With