Skip to content
Advertisement

Return list of True/ False bool value for list of leap years given as an argument

I have to check whether year = [1900, 2020, 2021, 2001] is a leap year or not and get True/False as a result (Boolean)

I have written a function as :

JavaScript

But now I need to pass a list as year = [1900, 2020, 2021, 2001] and when I am doing so I am getting an error as “TypeError: unsupported operand type(s) for %: ‘list’ and ‘int'”

How do I pass a list as an argument in a function?

Advertisement

Answer

You can simply do this:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement