Example:
integer_no = 0101
print(integer_no)
Error:
SyntaxError: leading zeros in decimal integer literals are not permitted;
use an 0o prefix for octal integers
Reason for leading zero SyntaxError
In Python Programming, leading zeroes to a number value is not allowed, as having a leading zero, the number (assumed to be decimal - base 10) is considered to be an Oactal number (to the base 8)
But even to represent a number of octal (base 8( type, you have to add prefix 0o (Numeric 0 followed by lowercase letter o)
Solution/Fix
There could be one of these solutions based on what you are trying to achieve.
1. If the number is a decimal number
Example:
decimal_no = 101
2. If the number is an octal number
Example:
octal_no = 0o101
3. If the value is to be a String
Example:
string = "0101"
Facing issues? Have Questions? Post them here! I am happy to answer!
- Python List of Lists with Examples
- Fix: ERROR: Could not find a version that satisfies the requirement tkinter (from versions: none) ERROR: No matching distribution found for tkinter
- How to Convert Python Notebook .ipynb (JSON) to Executable .py Module
- ModuleNotFoundError: No module named qdarkstyle.colorsystem [Python]
- Python: Pandas Merge Indicator (Left, Right and Both) Example
- Fix: EOFError Exception in Python
- How to URL Decode a Query String in Python
- How to take user input from the console in a Python program
- Compare two lists in Python and return matches
- How to change the Python Default version
- Fix: KeyError: exception in Python
- How to get the Execution Time of A Python Program
- Fix: ModuleNotFoundError: No module named boto3 [Python]
- How to get unique values from a list in Python
- How to pip install Python Modules in VSCode
- Python: Fix - TypeError: NoneType object is not iterable
- How to delete a file using Python code example
- How to create a dictionary comprehension in Python
- Python: Get just the filename without extension using Path
- How to comment out a block of code in Python
- How to add two float numbers in Python
- Python: How to POST Json Data with HTTP Request
- Get MD5 Hash as Checksum of a String in Python
- Python - Convert float to String
- How to Parse XML String in Python
- Install Native Golang on M1/M2 ARM based Mac - MacOS
- Notepad++ Export file as HTML - NotepadPlusPlus
- CRUD operations in Spring Boot + JDBC - Java
- Online Free JSON String Formatter (Prettifier) Tool - Tools
- How do I run HTML file in Notepad? (Windows) - NotepadPlusPlus
- Only Chessboard using HTML and CSS Code Example - CSS
- Fix: MySQL: ERROR 1044 (42000): Access denied for user @localhost to database - MySQL
- Java Program: Random Number Generator - Java