Computer Science

Find the error. Consider the following code and predict the error(s):

y for y in range(100) if y % 2 == 0 and if y % 5 == 0

Linear Lists

1 Like

Answer

  1. The list comprehensions should be enclosed in square brackets.
  2. The code contains a syntax error as it is using two if statements within the list comprehension. We should use a single if statement with both conditions combined using the and operator.

Answered By

1 Like


Related Questions