Ayush Gupta

Ayush Gupta

2 Articles Published

Articles by Ayush Gupta

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 146 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))

Read More

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

Ayush Gupta
Ayush Gupta
Updated on 06-Mar-2020 220 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

Read More
Showing 1–2 of 2 articles
« Prev 1 Next »
Advertisements