Q. What will be the output of the following code snippet?
Tup1 = ((1, 2),) * 7
print (len(Tup1 [3: 8 ]))
Answer =
Output is: -
4
>>>
Because
Tup1 = ((1, 2),) * 7
After this Tup1 become
((1, 2), (1, 2), (1, 2), (1, 2), (1, 2), (1, 2), (1, 2))
Now Len(Tup1[3:8]) strat from index number 3 , 4, 5, 6.
So, output is 4.
Can you explain me?
ReplyDeleteTup1 = ((1, 2),) * 7
DeleteAfter this Tup1 become
((1, 2), (1, 2), (1, 2), (1, 2), (1, 2), (1, 2), (1, 2))
Now Len(Tup1[3:8]) strat from index number 3 , 4, 5, 6.
So, output is 4.
it is asking length
DeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )