App Working on Localhost but not Live Server (KeyError Everytime)

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:
streanlit-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! :wave:

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