0

is there any way to use integer value with leading 0 Python?

0b is for binary 0o for octal but what to do for leading 0 in integer values in Python https://code.sololearn.com/cfQe6Ub4ddJV/?ref=app

31st Jan 2020, 2:57 PM
Kishor Jena
Kishor Jena - avatar
4 Respuestas
+ 4
The method input() always returns a string. In your prog the variable userinput is not a string. That might be confusing you
31st Jan 2020, 3:22 PM
Oma Falk
Oma Falk - avatar
+ 3
User enters 01234 and u want to go on with 1234 right?
31st Jan 2020, 3:10 PM
Oma Falk
Oma Falk - avatar
+ 3
print ('{:010d}'.format(12345))
31st Jan 2020, 3:44 PM
Sebastian Keßler
Sebastian Keßler - avatar
+ 1
you can use string. and use int() when you need it as an int. since int() will convert to base 10 by default you dont have to worry for it to be octal https://code.sololearn.com/cxd5QuYsp5mP/?ref=app
31st Jan 2020, 3:03 PM
Taste
Taste - avatar