0
I don't understand this python code, please anyone share the explanation how this code execute🤷. {Code in the description}
list1 = [3 , 2 , 5 , 6 , 0 , 7, 9] sum = 0 sum1 = 0 for elem in list1: if (elem % 2 == 0): sum = sum + elem continue if (elem % 3 == 0): sum1 = sum1 + elem print(sum , end=" ") print(sum1) #Output:8 12 but how?? 🤷♂️🤷♂️
1 Odpowiedź
+ 2
Code_with_gaurav...
There is continue used in 1st if condition so on every even number (elem % 2 == 0) it will skip current iteration and move for next iteration.
In 2nd if statement there is elem % 3 == 0 means whichever element is divisible by 3 that will be add. So here 3 and 9 is divisible by 3
So 3 + 9 = 12