
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"
Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!