
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Python: Cannot understand why the error - cannot concatenate 'str' and 'int' object ?
This can be corrected by putting n+1 in brackets i.e. (n+1)
for num in range(5): print ("%d" % (num+1))
Using %d casts the object following % to string. Since a string object can't be concatnated with a number (1 in this case) interpreter displays typeerror.
- Related Articles
- Python: Can not understand why I am getting the error: Can not concatenate 'int' and 'str' object
- How can I concatenate str and int objects in Python?
- Why cannot solids be compressed?
- What can cause the "cannot find symbol" error in Java?
- TestNG error:- Cannot find class in classpath using Selenium
- Why human cannot inhale carbon dioxide?
- What can cause a Cannot find symbol error in java?
- Why constructor cannot be final in Java
- Why a constructor cannot be final in Java?
- Why we cannot digest cellulose as cattle do?
- Non-metals cannot be drawn into wires. Why?
- Why We Cannot Taste The Food Properly While Having Cold
- Why in MySQL, we cannot use arithmetic operators like ‘=’, ‘
- Why an interface cannot implement another interface in Java?
- Why humans cannot digest grass but can digest lemongrass?

Advertisements