python - How to check if some characters are in a string using Boolean? -
if want know whether characters found in string, how? string returned boolean. body below :
return true if letters 'a', 't', 'c' or 'g' found in string. homecoming false if not.
def is_valid_sequence(dna):
>>> is_valid_sequence('atcg') true >>> is_valid_sequence('atcgeq') false how write code? give thanks you.
as suggested in reply - how check string specific characters?
def is_valid(dna) if 'a' or 't' or 'g' or 'c' in dna: homecoming true else: homecoming false python string boolean character
No comments:
Post a Comment