In Python strings have a method lower()
:
>>> dir('A')
[... 'ljust', 'lower', 'lstrip', ...]
However, when one tries '{0.lower()}'.format('A')
, the response states:
>>> '{0.lower()}'.format('A')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'str' object has no attribute 'lower()'
Can someone help me understand why the line above throws an AttributeError in this case? This seems like it should not be an AttributeError, though I must be mistaken. Any help understanding this would be very welcome!
Edit: I understand I can't call the lower() method inside the format call (though it'd be neat if that were possible); my question is why doing so throws an AttributeError. This error seems misleading in this case.