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

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -