Python Forum

Full Version: str object is not callable
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello, I need help. Me not have experience to use Python. Can anyone help me how to fix it ? Thank you.

i: int=0
for group in groups:
    print('['(int(i)+']' - '+group.title'))
    i+=1
Explanation coming out

Error:
SyntaxWarning: 'str' object is not callable; perhaps you missed a comma? print('['(int(i)+']' - '+group.title')) TypeError: unsupported operand type(s) for +: 'int' and 'str'
I think that error message is quite explicit

Error:
TypeError: unsupported operand type(s) for +: 'int' and 'str'
You are trying to add int(i) to ']' and this will raise an error.

How to fix? In general terms - operands must be same type (either int or str) but other than that - no idea as there is no clue what the desired result is.
If in the .py file I first use the str variable then it all has to declare str as well ?