My function is:
def searchstock():
dictionary=calcreturn(dictionize(tickers(openfile()),pairslist()))
inp=raw_input("What is the stock ticker? ")
while True:
try:
dictionary[inp]
break
except KeyError:
print("Ticker not found. Please input again ")
print(inp, dictionary[inp])
the try/except doesnt work. I'm trying to see if a user input is in the dictionary keys and then return the key and respective value
If imp is not in the dictionary, why would this be an infinite loop?