<jupyter_start><jupyter_text>Lesson 6 - Iterations<jupyter_code>seq = 'GACTACATGACTGACTTAGCCGTGACATGGTAAATG'

# Initialize GC counter
n_gc = 0

# Initialize sequence length
len_seq = 0

#Iterate through sequence and count G's and C's
for base in seq:
    len_seq +=1
    if base in 'GCgc':
        n_gc += 1
        
# Get GC content by dividing
n_gc / len_seq<jupyter_output><empty_output><jupyter_text>seq is an iterable. for loop = for 'variable (or item)' in 'iterable'<jupyter_code>len(seq)
my_integers = [1, 2, 3, 4, 5]

for n in my_integers: 
    n *= 2
    
my_integers<jupyter_output><empty_output><jupyter_text>Doesn't work because you are aking for change to be made to the original list<jupyter_code>for i in range(5):
    my_integers[i] *= 2
    
my_integers<jupyter_output><empty_output><jupyter_text>But you can get around it by indexing, the second line my_integers[i] is where you are updating the values in the list<jupyter_code># Find index of all G's in a sequence
len_seq = 0

for base in seq: 
    if base == 'G':
        print (len_seq)
    len_seq +=1
for i, base in enumerate(seq):
    if base =='G':
        print(i, base)<jupyter_output>0 G
8 G
12 G
18 G
21 G
23 G
28 G
29 G
35 G<jupyter_text>enumerate gives you the index and the value for that item / variable<jupyter_code>names = ('Dunn', 'Ertz', 'Lavelle', 'Rapinoe')
positions = ('D', 'MF', 'MF', 'F')
numbers = (19, 8, 16, 15)

for num, pos, name in zip(numbers, positions, names):
    print (num, pos, name)
count_up = ('ignition', 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)

for count in reversed(count_up):
    print(count)
seq = 'AUCGAUGCAGUAGCAUGCAAGUC'
start_codon = 'AUG'

# Initialized the sequence index
i = 0 

# Scan the sequence until I hit the start codon
while seq[i:i+3] != start_codon and i < len(seq):
    i+=1

if i == len(seq):
    print ('Start codon was not found.')
else: 
    print ('The start codon starts at index', i)<jupyter_output>The start codon starts at index 4<jupyter_text>while loops, evaluates until boolean returns false; if you don't know how many loops it's going to have to run, run while loops<jupyter_code>seq [100:103]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10828320222119389, 'fraction_numerical': 0.027302174919018974, 'mean_word_length': 4.159904534606206, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 23, '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': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '479128', 'license': 'CC-BY-4.0', 'n_tokens_mistral': 865, 'n_tokens_neox': 798, 'n_words': 281, 'path': 'lessons/lesson_06.ipynb', 'repo_name': 'jeesoo-js/bootcamp', 'size': '2161'}