Computer Science, asked by Trishna2367, 10 months ago

Write a list comprehension that builds a list of the even numbers from 1 to 10 (inclusive).

Answers

Answered by Anonymous
0

The list comprehension for the given question is as follows:

[x for x in range(1, 11) if x%2==0]

  • In python, list comprehension is an easy and compact syntax for creating a list from a string or another list.
  • In this program, if statement is used in a list comprehension.
  • The following program will produce an output in the form of a list in which all even numbers between 1 and 10 are printed.

Similar questions