+ 1

Can someone explain this code for me?

What is the output of this code? a=[x for in range(4)] print(sum(a[1::-2]+a[::-3]))

19th Apr 2017, 4:17 PM
Hridoy
Hridoy - avatar
3 Respostas
+ 1
There is a problem: a = [x for in range(4)] there is no variable before the "in", so this is a syntax error
19th Apr 2017, 4:34 PM
Amaras A
Amaras A - avatar
+ 1
Have a look at the corrected and commented source at https://code.sololearn.com/c9DA0Yd9E699
19th Apr 2017, 5:24 PM
Klaus-Dieter Warzecha
Klaus-Dieter Warzecha - avatar
0
it was a question of a quiz. the given answer is 4. But I cant understand the mechanism
19th Apr 2017, 4:46 PM
Hridoy
Hridoy - avatar