Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Number in python - 010 [duplicate]

Possible Duplicate:
How do you express binary literals in Python?

When using the interactive shell:

print 010

I get back an 8.

I started playing around using other numbers having zeroes before (0110 = 72, 013 = 11) but I could not figure it out...

What is going on here?

like image 516
AlexBrand Avatar asked Nov 26 '25 16:11

AlexBrand


1 Answers

Numbers entered with a leading zero are interpreted as octal (base 8).

007 == 7
010 == 8
011 == 9
like image 131
MikeyB Avatar answered Nov 29 '25 05:11

MikeyB



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!