CBSE Class 12 Computer Science Question 62 of 68

Data Structures - I : Linear Lists — Question 18

Back to all questions
18
Question

Question 16

Find the error in the following list comprehension :

["good" if i < 3: else: "better" for i in range(6)]
Answer

The code contains a syntax error due to the placement of the colon (:). There should not be colon in list comprehension.