Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Format An Integer To Show Leading Spaces

1 REPLY 1
SOLVED
Reply
Message 1 of 2
isocam
175 Views, 1 Reply

Format An Integer To Show Leading Spaces

Can anybody help?

 

How do you format an integer to show leading spaces?

 

For example,

 

1 should be          "   1"                    (3-leading spaces)

10 should be       "  10"                   (2-leading spaces)

100 should be    " 100"                  (1-leading space)

1000 should be "1000"                  (No leading spaces)

 

Many thanks in advance!

 

Darren

1 REPLY 1
Message 2 of 2
kandennti
in reply to: isocam

Hi @isocam .

 

Try this.

        numbers = [1,10,100,1000]
        for num in numbers:
            print('{:>4}'.format(num))

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report