+ 1

Why output is 7

a = [(1,0)[2,3,1],{1:'a',4:'b'}] lst = [] for n in a: lst.extend(n) print(len(lst)) #output 7

14th Jul 2020, 10:25 AM
Emon
2 ответов
+ 5
Because its 7 elements in list 1 0 2 3 1 a b
14th Jul 2020, 10:29 AM
Shahghasi Adil
Shahghasi Adil - avatar
+ 1
You could have checked yourself as well ,print is a very useful function ,if you don't understand something ,using print to see the output after a step and try to understand it Like in the example above place a print(lst) statement after lst.extend
14th Jul 2020, 10:34 AM
Abhay
Abhay - avatar