proId = 'nam001'
I want to increment numeric values only. That should be like this 'nam002', 'nam003'. How to do this?
proId = 'nam001'
I want to increment numeric values only. That should be like this 'nam002', 'nam003'. How to do this?
Just because you asked nicely :D
You can use the simplest for
loop, with str.zfill
to pad with zeroes, then add it to the 'nam'
prefix like this:
for i in range(1,11):
proId = 'nam' + str(i).zfill(3)
print(proId) # or do whatever you need with it...
Output:
nam001
nam002
...
nam009
nam010