python - How can you check for specific characters in a string? -
when run program prints true. example, if enter aajj print true because checking if first letter true. can point me in right direction? thanks!
squence_str = raw_input("enter either dna, protein or rna sequence:") def dnacheck(): in (squence_str): if string.upper(i) =="a": return true elif string.upper(i) == "t": return true elif string.upper(i) == "c": return true elif string.upper(i) == "g": return true else: return false print "dna ", dnacheck()
you need check all of bases in dna sequence valid.
def dnacheck(sequence): return all(base.upper() in ('a', 'c', 't', 'g') base in sequence)
Comments
Post a Comment