Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles by Ayush Gupta
2 articles
Python: Can not understand why I am getting the error: Can not concatenate 'int' and 'str' object
This error occurs when Python tries to concatenate (combine) an integer and a string using the + operator. Python cannot automatically convert between these data types during concatenation operations. Common Cause of the Error The error typically happens when using string formatting with %d placeholder. If you write %d % i + 1, Python interprets this as trying to add the integer 1 to the formatted string result. Incorrect Code (Causes Error) i = 5 # This causes the error - operator precedence issue print("Num %d" % i + 1) Solution: Use Parentheses ...
Read MoreTypeError: __init__() takes exactly 1 argument (5 given)
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