Ayush Gupta has Published 2 Articles

Python: Can not understand why I am getting the error: Can not concatenate 'int' and 'str' object

Ayush Gupta

Ayush Gupta

Updated on 12-Mar-2020 12:31:58

70 Views

This error is coming because the interpreter is replacing the %d with i and then trying to add 1 to a str, ie, adding a str and an int. In order to correct this, just surround the i+1 in parentheses. exampleprint("\ Num %d" % (i+1))

TypeError: __init__() takes exactly 1 argument (5 given)

Ayush Gupta

Ayush Gupta

Updated on 06-Mar-2020 05:09:08

106 Views

You need to indent all the method definitions so that they are under the class. exampleclass A(): def __init__(): passYou can learn more about indentation and how it needs to be used in Python here −https://www.tutorialspoint.com/python_online_training/python_lines_and_indentation.asp

1
Advertisements