I want to search a python dictionary for a key that matches an initial sequence of letters. However, it's a bit more complicated and I lost myself midway in confusion.
Example: I have a string "ABSTTHGIHG" and i want to search a dictionary for a key that matches exactly the last 9 letters of the string. If none is found i want to search another dictionary for a key that matches exactly the last 8 letters of the string.
I have no idea how to match a specific number of letters (here "the last x letters") with a key (or how to search for a key) so i have hopes that somebody here can perhaps name a function that enables me to do so or where i can look it up.
There is no code that i can present since this would be the first thing the program does.
Can i specify "the last 9 letters" with something like x = string[1:]
? That would be the only idea i have how to specify which letters of the string to use for the search.