KeyError and TypeError - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: KeyError and TypeError (/thread-40518.html) |
KeyError and TypeError - deneme2 - Aug-10-2023 Hello Friends, When I use this one if "Corners." in matches["matchInfosFull"]: continueit gives this error When I use this second one:if "Corners." in matches.get("matchInfosFull"): continueit gives this error When I use this third one:if "Corners." in [matches.get("matchInfosFull")]: continueit does not give any error but it does not apply any filter to the output with "if-continue" phrase Anyone has an idea to solve it? Thanks for your interest and time. RE: KeyError and TypeError - deanhystad - Aug-10-2023 "matchInfosFull" is not in the matches dictionary. The way to solve it is only use keys that appear in the dictionary. I suppose you could do this: if "Corners." in matches.get("matchInfosFull", []): continueThis returns an empty list when matchInfosFull is not in matches. RE: KeyError and TypeError - deneme2 - Aug-10-2023 Yep, thats it @deanhystad. It worked out buddy, it solved. Thank you, thanks a lot for your time. btw: your nickname reminds me tough scandinavian centre back players in the premier league |