0

How do I convert this code to a string?

*This* is the *code* : n= int(input()) for x in range(1,n): if x%3==0 and x%5==0: print(str(x)+"SoloLearn") gives me this error: print(str(x)+"SoloLearn") TypeError: 'list' object is not callable what I wanted was to have both number and "SoloLearn" to be added together, ofcourse this could be done if I changed + to a ,(comma) and that would work but what I don't understand is why can't I change x to a string and add it? Edit: I see that you can do this through sololearn coding but when I do this in an actual python IDE (PyCharm) the code gives me an error.

10th Jan 2021, 8:54 PM
Ace
Ace - avatar
2 Antworten
+ 5
If you get "list object is not callable" error on line print(str(x) +"SoloLearn") then most probably somewhere before you defined a list variable called 'str' which has shadowed the str constructor (or mabe you have list variable called 'print' but it seems to be rarer)
10th Jan 2021, 9:35 PM
Volodymyr Chelnokov
Volodymyr Chelnokov - avatar
+ 1
I entered input 30 and output was 15Sololearn so works fine I guess!
10th Jan 2021, 8:58 PM
Abhay
Abhay - avatar