How to add padding to a number in Python

1 Answer

0 votes
n = 973
 
padding = '0'
 
length = 8
 
n = str(n).rjust(length, padding)
 
print(n)    
 
 
'''
run:
 
00000973
 
'''

 



answered Sep 21, 2023 by avibootz

Related questions

1 answer 129 views
129 views asked Sep 20, 2023 by avibootz
1 answer 161 views
1 answer 214 views
3 answers 250 views
...