Skip to content

Filter function in Python #100352

@ghost

Description

I am running a pring using filter function, everytime it is giving the output of list [1,2,3,4,5,6,7,8,9,10] means list of 1 to no enter I entered, if I enter 0 as starting no, it's still giving output from 1.
Program -
def square(x):
return(x**2)
squares = []
squares = list(filter(square, range(0,11)))
print("List of squares in the range 1-10 = ", squares)

Output - List of squares in the range 1-10 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
// The output should be squares of the numbers.

Metadata

Metadata

Assignees

Labels

*caused-by-extensionIssue identified to be caused by an extension

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions