I am running into errors with python dictionaries and it shouldnât be!
The method of accessing and updating them are correct and works fine on localhost but the live server seems to be on a mission to frustrate me. All dictionary items keeps returning âKeyErrorâ and it shouldnât be!
This is the code snippet below:
It correctly produces the following result on localhost:

But on the live server (streamlit cloud), it wrongly flags my python dictionary, raising a keyError:
finals_dict[str(h[âOutcomeâ][i] + â Playedâ)] = h[âTieâ][i]
Hi @fesomadealli! 
Welcome to the Streamlit community â Itâs great to have you here!
In the code snippet youâve shared, it seems that youâre accessing keys in finals_dict
using dynamic names based on the content of the dataframe h
.
The KeyError
may happen if the Outcome
column in h
on the live server has different values than what you expect or what you have on localhost. This can happen due to differences in the data, the environment, or the way the dataframe is being processed.
Would it be possible for you to share the full code for a better diagnosis, please?
Best,
Charly