rookie here. Can anyone tell me what is wrong with this? I cant seem to print my “primer” string, I am sure that the “region” variable is not empty for I tested it out already.
Advertisement
Answer
In the future, please post the text of your program, not an image of the program.
I modified your program to do what I think your intent was.
The main thing you needed to do was call complement(region) and assign the return value to a variable.
JavaScript
x
23
23
1
dna = "ATCGATCGATCGTAGCTAGCTAGCTAGCTAGCTAGCTAGCTAGCTAGCTAGCTAGCTAG"
2
print(f"#1 'dna' len={len(dna)} {dna}")
3
4
start = "3"
5
end = "30"
6
dna = dna[int(start):int(end)]
7
print(f"#2 'dna' len={len(dna)} {dna}")
8
9
region = dna[0:20]
10
print(f"#2 'region' len={len(region)} {region}")
11
12
13
def complement(region):
14
comp = {'A': 'T', 'T': 'A', 'C': 'G', 'G': 'C'}
15
primer = ''
16
for i in region:
17
primer = primer + comp[i]
18
return primer
19
20
com = complement(region)
21
22
print(f"'complement' len={len(com)} {com}")
23