vendredi 13 octobre 2017

Python I cant replace my stringvalues

Im programming in Visual Code Studio with Python3

So my first function generates a DNA String and my second function should replace 1 of the pairs from that string with two different ones. What am I doing wrong here. ( The error I get starts with wrong syntax)

Thanks ahead for helping

import random as rd


def generateVirus(length):
    a = [rd.choice(["AT", "GC","TA", "CG"])for i in range(length)]
    return ("".join(a))


def mutate(virus):
    virus = [v.replace(virus[int(rd.random()*(len(virus+1))), rd.choice([virus]for v in virus]
    return virus

a = generateVirus(4)
b = virus(a)




Aucun commentaire:

Enregistrer un commentaire