Code with the error

word = "python"
print(word.shout())

Error message (Python 3.12, last line)

AttributeError: 'str' object has no attribute 'shout'

Corrected code

word = "python"
print(word.upper())

Output

PYTHON

Common causes

  • A method name is misspelled or invented.
  • A list method is called on a string, or the other way round.
  • The value is None, often because a method such as list.sort() returns nothing.
  • Wrong letter case: Upper() instead of upper().

Practise in the course

Lesson: String Methods

Frequently asked questions

Why do I see “NoneType object has no attribute”?

The variable holds None. Find where it got its value: some methods change a list in place and return None.

How do I know which methods a string has?

See the lesson on string methods or the official Python documentation for str.