python - Accessing keys in dictionaries -
if wanted access keys in dictionary , check if sequences (atgc) key have "gc". how access keys check if contains string "gc"?
many thanks!
matches = [ k k in yourdictionary.keys() if 'gc' in k.lower() ] number_of_matches = len(matches)
you regex
or string.find
( returns -1 if not found ) or string.count
-- if substring in string
works , cleaner illustrate point. cast key lowercase , compared against lowercase string, case insensitive match.
Comments
Post a Comment