<jupyter_start><jupyter_text>For and Tuples<jupyter_code>person = ('John', 'Silver', 22)
for item in person:
    print(item)
#many funcs return list of tuples
persons = [('John', 22), ('Bob', 32), ('Dave', 20)]
len(persons)
#tuple unpacking
#for name, age in persons:
for (name, age) in persons:
    print(f'{name} is {age} years old')<jupyter_output>John is 22 years old
Bob is 32 years old
Dave is 20 years old<jupyter_text>For and Dict<jupyter_code>players = dict(Carlsen=2842, Caruana=2822, Mamedyarov=2801, Ding=2797, Giri=2780)
for item in players:
    print(item)
for item in players.items():
    print(item)
#tuple unpacking
for k,v in players.items():
    print(f'{k} has rating {v}')
for v in players.values():
    print(v)
#find all pairs sum of which equals 0
list1 = [2, 4, -5, 6, 8, -2,]
list2 = [2, -6, 8, 3, 5, -2,]

pairs = []
for x in list1:
    for y in list2:
        cur_sum = x + y
        if cur_sum == 0:
            pairs.append((x, y))
pairs<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14744232698094284, 'fraction_numerical': 0.05215646940822467, 'mean_word_length': 3.916256157635468, 'pattern_counts': {'":': 0, '<': 8, '<?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': '223717', 'license': 'MIT', 'n_tokens_mistral': 433, 'n_tokens_neox': 394, 'n_words': 128, 'path': 'notebooks/Python3-Language/03-Collections, loops and logic in Python/08-For Loops.ipynb', 'repo_name': 'binakot/Python3-Course', 'size': '997'}