[Tutor] Function that returns True if a list contains odd number else return False
Manprit Singh
manpritsinghece at gmail.com
Thu Mar 10 12:14:34 EST 2022
Dear Sir,
This may be an inappropriate question, just thinking about it and writing,
so I was to make a function that can accept a list as an argument and
returns True if the list contains an odd number else the function should
return False .
Above problem can be solved in two way :
Inside a user defined function just returning
1) any(1 for ele in seq if ele%2)
2) any(ele%2 for ele in seq)
where seq is the formal parameter of the function.
Which one is more appropriate ?
Regards
Manprit Singh
More information about the Tutor
mailing list