+ 1
x=[] for y in range(5): if y[b] % [/b]2==0: x.append(y) continue print (x)
How does if statement work and what is output
4 Antworten
+ 8
[b] and [/b] are formatting annotations (bbcode), which should NOT be part of your actual code. It is markup for bold text. If you remove them, the code will work.
+ 10
Please DO NOT put code in the title section.
You can find out WHAT the output is by actually running the code.
+ 9
Somvir Dhaka ,
the code you presented is very buggy.
> in line 2, numbers are created by using a range().
> in line 3 the code uses indexes to access the numbers (coming from the range) like *y[b]*, but this fails since numbers are not subscriptable.
also the indexes itself are creating errors, because *b* is never defined, also */b* does not work.
> also the *continue statement* in line 5 has no effect.
> so the complete line 3 is a total mess.
may be you correct the code so that we can help you ?
what is this code going to achieve?
+ 6
It says syntax error. It points to line 3.
And you have already finished 4 python courses. This should be easy for you.