<jupyter_start><jupyter_text>enumerate()In this lecture we will learn about an extremely useful built-in function: enumerate(). Enumerate allows you to keep a count as you iterate through an object. It does this by returning a tuple in the form (count,element). The function itself is equivalent to:    def enumerate(sequence, start=0):        n = start        for elem in sequence:            yield n, elem            n += 1Example<jupyter_code>lst = ['a','b','c']

for number,item in enumerate(lst):
    print number
    print item<jupyter_output>0
a
1
b
2
c<jupyter_text>enumerate() becomes particularly useful when you have a case where you need to have some sort of tracker. For example:<jupyter_code>for count,item in enumerate(lst):
    if count >= 2:
        break
    else:
        print item<jupyter_output>a
b
{'fraction_non_alphanumeric': 0.07804878048780488, 'fraction_numerical': 0.007317073170731708, 'mean_word_length': 3.510989010989011, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '16284', 'license': 'MIT', 'n_tokens_mistral': 242, 'n_tokens_neox': 235, 'n_words': 101, 'path': 'Django2.0-Python-Full-Stack-Web-Developer/TravlersDayOneandTwo/4- Advanced Features in Python/1 - Built In functions/Enumerate .ipynb', 'repo_name': 'nobodysshadow/udemy_django', 'size': '820'}