How do I turn the number 120 to 00120 in python?

  • Context: Python 
  • Thread starter Thread starter vorcil
  • Start date Start date
  • Tags Tags
    Python
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 replies · 2K views
vorcil
Messages
395
Reaction score
0

Homework Statement



I need to know how to change the format of a number in python

for example if I have a integer variable, xstart=0.
If i were to print(xstart) I want it to show 00000
and if I were to add 120 to xstart
xstart+=120
then print it
print(xstart) I want it to show 00120

Thanks.

Homework Equations





The Attempt at a Solution

 
on Phys.org