Skip to content

Instantly share code, notes, and snippets.

@NathanW2
Last active January 3, 2021 06:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NathanW2/8113514 to your computer and use it in GitHub Desktop.
Save NathanW2/8113514 to your computer and use it in GitHub Desktop.
def counter(start, interval):
count = start
while True:
yield count
count += interval
count = counter(start=1, interval=1)
def autoIncrement():
return str(count.next()).zfill(3)
>> print autoIncrement()
001
>> print autoIncrement()
002
>> print autoIncrement()
003
>> print autoIncrement()
004
>> print autoIncrement()
005
>> print autoIncrement()
006
>> print autoIncrement()
007
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment