I am trying to generate random sequences of DNA in python using random numbers and random strings. But I am getting only one string as my output. For example: If I give DNA of length 5 (String(5)), I should get an output "CTGAT". Similarly if I give String(4) it should give me "CTGT". But I am getting "G" or "C" or "T" or "A"; i.e. only a single string each time. Could anyone please help me with this??
I tried the following code:
from random import choice
def String(length):
DNA=""
for count in range(length):
DNA+=choice("CGTA")
return DNA