0

A stupid challenge here!Multiply all elements in a list using pop method only.

Like this:a=[1,2,3] p1=a.pop() p2=a.pop().....pop every single one in a list,and multiply all of them,do we have to list all the p1,p2,....p(len(a)) viarables?

15th Oct 2017, 2:13 PM
lwluowei
2 ответов
+ 2
"while list:" will return False when a list is empty. Pop() removes elements so we can loop through the list instead of assigning a variable to each list element. Take a look at my example: https://code.sololearn.com/cHxAbSj4Np1j/?ref=app
15th Oct 2017, 2:45 PM
Nic
0
Stupid challenge ask for stupid answers. One liner of course. https://code.sololearn.com/cR0xv1XMonf6/?ref=app
15th Oct 2017, 3:16 PM
VcC
VcC - avatar