How to fix AttributeError: 'str' object has no attribute 'method' in Python | DevErrors