0
Why is the output of the code:(0,2,2) instead of ((0,),(2,),(2,))
9 Answers
+ 5
Check out the output of the 4th line. You will understand yourself..
https://code.sololearn.com/cjWNm1tAJWE8/?ref=app
+ 2
You can build nested tuples, but not with the multiplication operator.
t1 = 0, 1
print(t1)
t2 = t1, t1
print(t2)
+ 2
Here is how you can achieve the output you asked:
https://code.sololearn.com/cQG9m1bdWDTO/?ref=app
+ 2
mutible is tuple
+ 2
šš¢š¢ššØ šš”šš²šš„ your code works too.
The multiplication of list and tuple works consistently in Python.
print((1,) * 5) # tuple of 5
print([1] * 5) # list of 5
0
Why can't we form a nested tuple , like nested lists?
0
Well that's my question?