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

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

monitor web browser programmatically in Android? -

c# - Using multiple datasets in RDLC -