Python List functions – enumerate

List Functions

Often used in conditional statements, all and any take a list as an argument, and return True if all or any (respectively) of their arguments evaluate to True (and False otherwise).
The function enumerate can be used to iterate through the values and indices of a list simultaneously.
Example:

l = [110,20,40]
for i in enumerate(l):
print(i)

Output: (0, 110)
(1, 20)
(2, 40)

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Design a site like this with WordPress.com
Get started