any
PY-W0074It is recommended to use any
for this loop, as it will make your code smaller and more readable.
def has_ten(my_list):
for item in my_list:
if item == 10:
return True
return False
def has_ten(my_list):
return any(item == 10 for item in my_list)