Module 3
Looping through text
Processing each character of a string.
One character at a time
You can loop through a string to process each character. This is extremely useful in bioinformatics.
Python
for base in "ATGC":
print(base)→ A
T
G
C
Each character of the string is visited in order. You can count, filter, or transform each one.
Python
seq = "ATGC"
count = 0
for base in seq:
count = count + 1
print(count)→ 4
Your task
Count with a loop
- Loop through ATGC and count the characters. Print the count.