+ 1
Python Type Conversion
Why a space is added when below tuple is covered to string? shiv = (11,5,7,2,2) shiv = str(shiv) print (shiv) print (s[4])
5 Réponses
+ 2
Ok, but why is space added? The original tuple doesn't have any.
+ 1
Rini Even before converting it to string, it would have spaces.
You can remove the spaces after converting into by,
shiv = shiv.replace(" ", "")
+ 1
Rini original tuple HAS spaces after commas.
+ 1
Yes, you are right it has. I never paid attention to the output format. I couldn't find the exact reason why space is added after comma, but from what I read it is for better readability.
Thanks!
0
@Rini lol no problem :)