It's because you named your string variable `str` like the built in function. Try changing it to `s` or `string` like I have in the answer
– Have a nice dayMay 04 '21 at 17:28
>>> l = ['london', 'paris', 'beijing']
>>> s = str(l)
Traceback (most recent call last):
File "", line 1, in
TypeError: 'str' object is not callable
– PankajMay 04 '21 at 17:30