0
Why is the output of this code 7?
x=[[0],[1]] print(len(' '.join(list(map(str,x)))))
2 Answers
+ 4
Try putting this in the code and you will see:
print(list(map(str,x)))
x is a list that has two lists as elements, and each inner list has a number inside.
First, str converts those inner lists to string which looks like this:
'[0]', '[1]'
So these strings are 3 characters long each (including the brackets).
Then they are joined by a whitespace so the final string is:
'[0] [1]'
which is 7 characters long, thus the result.
+ 2
Thanks a lot