x=2 y=3 z=[3,8,5] print(len(x*y*z)) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

x=2 y=3 z=[3,8,5] print(len(x*y*z))

Why the output is 18 ??

26th Nov 2019, 9:25 AM
Imtiaz Supto
Imtiaz Supto - avatar
4 Answers
+ 9
Imtiaz Supto as now you have updated the X value so x × y is number not an list elements so it will return 6 as multiplication then 6 is multiply with list Z 3 elements which result in print the list with 3 element 6 so it will give 18 elements so the length of Z list will become 18 so this way output is comes as 18 printing Z will return [1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3] which is length in 18
26th Nov 2019, 9:43 AM
GAWEN STEASY
GAWEN STEASY - avatar
+ 5
Imtiaz Supto output is 0 as x value is 0 how you come up with 18 ?
26th Nov 2019, 9:33 AM
GAWEN STEASY
GAWEN STEASY - avatar
+ 1
Oh sorry.... Yes the output is 0 but how...?? now it's 18
26th Nov 2019, 9:34 AM
Imtiaz Supto
Imtiaz Supto - avatar
+ 1
Oh really thanks....!! I understand it properly....!!!! 😊😇
26th Nov 2019, 1:26 PM
Imtiaz Supto
Imtiaz Supto - avatar