Get Unlimited Contributor Access to the all ExamTopics Exams!
Take advantage of PDF Files for 1000+ Exams along with community discussions and pass IT Certification Exams Easily.
my_list = [i for i in range(5,0,-1)]
m=[my_list[i] for i in range(5)] if my_list[i]%2==0
print(m)
#output SyntaxError: expected 'else' after 'if' expression
Ans is D
Answer is indeed D, due to the ] before the if statement.
If this bracket wouldnt be there, the result would be [4, 2].
my_list = [i for i in range(5,0,-1)]
m = [my_list[i] for i in range(5) if my_list[i] % 2 == 0]
print(m)
[4, 2]
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
seaverick
2 months, 3 weeks agokontra
11 months agogekkehenk
1 year agoandr3
1 year, 1 month agoRizos
1 year, 1 month agobesha
1 year, 9 months agoangelika_az
1 year, 10 months agomacxsz
1 year, 11 months ago