CBSE Class 12 Computer Science
Question 63 of 68
Data Structures - I : Linear Lists — Question 19
Back to all questions(i)
y for y in range(100) if y % 2 == 0 and if y % 5 == 0The list comprehension should be enclosed in square brackets, and we should use a single if statement with both conditions combined using the and operator.
The corrected code is:
[y for y in range(100) if y % 2 == 0 and y % 5 == 0](ii)
(y for y in range(100) if y % 2 == 0 and if y % 5 == 0)The list comprehension should be enclosed in square brackets, and we should use a single if statement with both conditions combined using the and operator.
The corrected code is:
[y for y in range(100) if y % 2 == 0 and y % 5 == 0](iii)
["good" if i < 3: else: "better" for i in range(6)]The list comprehension does not include colon.
The corrected code is:
["good" if i < 3 else "better" for i in range(6)]