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