+ 1

Write a function that input a dna string and outputs the complementary dna

a. Write a function, dna_strand, that accepts a string representing one side of the dna and returns the other complementary side. In DNA strings, symbols "A" and "T" are complements of each other, as "C" and "G". b. Using your function from part a), write a program that inputs a dna string and outputs the complementary dna. See sample runs below. Sample Run 1: Enter dna: CATGA dna complement: GTACT Sample Run 2: Enter dna: AAGGTTCC dna complement: TTCCAAGG Sample Run 3: Enter dna: ATTTTGGCCCATATAT dna complement: TAAAACCGGGTATATA So I have been trying to use the function that i wrote but it seems i cant figure out how to do part b. Thats my code so far: def dna_strand(n): if n=="A": print("T") elif n=="T" print("A") elif n=="C" print("G") elif n=="G" print("C") n = str(input("Enter dna:")) new_dna = str(input("Enter dna:")) How do you think I should continue ?

22nd Oct 2019, 5:53 PM
Apate
5 Respuestas
0
I added this to my code but now it wants me to write to DNA string, but i want my function to do it.
22nd Oct 2019, 6:50 PM
Apate
0
output error
22nd Oct 2019, 7:57 PM
Dedun Smit
Dedun Smit - avatar
0
You need to loop over the dna string and call the dna_strand for each nucleotide for n in new_dna: dna_strand(n)
23rd Oct 2019, 2:32 AM
xyz$