How to fix TypeError: string indices must be integers in Python | DevErrors