How auto increment a field using a range?

905
1
03-04-2017 07:40 AM
MaziziJama
New Contributor

I have an empty table with an integer type field, let us call it "field1"

I want to populate field1 with numbers ranging from 1-5, so that my table looks like this

OBJECTID      FIELD1

1                        1

2                        2

3                        3

4                        4

5                        5

I have come across this example - How To: Create sequential numbers in a field using Python in the Field Calculator 

But do not know how to adapt it to fit my need.

Regards,

0 Kudos
1 Reply
JoshuaBixby
MVP Esteemed Contributor

Similar question to In Field Calculator 1 To 9 Loop Numbers‌.

Pre-Logic Script Code:

from itertools import cycle
rot = cycle(range(1,6))
def next_number():
    return next(rot)


Value:
next_number()