Skip to content
Advertisement

How can resolve this error in Python: “TypeError: ‘str’ object is not callable” [closed]

How can I fix this error?

I’m facing this error on every example I’m trying to run. I’m new to Python and trying to add spaces in my code.

This is my code

spaces = '' * 12
print('add some spaces in this text' % spaces)

And I’m getting this error

TypeError: 'str' object is not callable

Advertisement

Answer

fix

spaces= ' ' * 12
print('add some spaces in this text'.replace(' ', spaces))

output

add            some            spaces            in            this            text
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement