Hi guys i need help with one thing in Python...
I've got something like

number=001 
example = "picture%d" % number 
print example ---> But it prints picture1 not picture 001....

and i need it as integer not as string because i want to use

--->

number=number + 2 for example...

Thank You guys, sorry for my English, and I hope that you understood

assert type(number) == int

But if you want to increment number. Number is already int type.

Gribouillis want to stop counter wrap arround to stop program destroying files. Rename = move in Linux systems. Good thinking.

commented: Thanks for your support ! +5

I've solved it, Thank You very much guys :)

Gribouillis want to stop counter wrap arround to stop program destroying files. Rename = move in Linux systems. Good thinking.

I read a good rule: assert the most obvious hypotheses about your data :)

Maybe the reason rwas not like I said as formatting normally expands if number does not fit. Still it is easy to optimize out assert statements because they make your dear program slower. Premature optimization is not without reason sin in Python world.

Maybe the reason rwas not like I said as formatting normally expands if number does not fit. Still it is easy to optimize out assert statements because they make your dear program slower. Premature optimization is not without reason sin in Python world.

My idea is that if the OP wanted larger numbers, he would have written picture0001, so there was an implicit assumption which deserved to be checked.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.