I wrestled with this for several hours, the figured it out. Of course it seems painfully obvious to me now, but maybe one day someone else will get stuck in the same place, so I thought I'd ask-and-answer. Of course any corrections or interpretations are welcome.
Abridged code:
bearNames = {
'grizzly' : 'GZ',
'brown' : 'BR',
}
bearAttributes = {
'GZ' : 'huge and light brown',
'BR' : 'medium and dark brown',
}
print("Type the name of a bear:")
userBear = input("Bear: ")
beartruth = True
while beartruth == True:
try:
print("Abbreviation is ", bearNames[userBear])
print("Attributes are ", bearAttributes[bearNames[userBear]])
print("beartruth: ", beartruth)
beartruth = False
print("beartruth: ", beartruth)
except:
print("Something went wrong - did you not type a bear name?")
print("beartruth: ", beartruth)
Problem - entering something which isn't a bear loops the "except" part forever. What I want to happen should be fairly obvious - if the user enters something which isn't in bearNames, it should trigger the except, print the error and head back to try.