how to increment mac address in python
<p>I am trying to send a request with name, id.no and mac address. This process i need to do for 100 times. i mean 100 different names and id.no's and mac address. I tried doing this. I want output as name1, 1234567679 and aa:bb:cc:dd:11:22.  can someone please help me. I have pasted my code and output below </p>

<pre><code>for i in range (1,10):
    name = 'name'+str(i)
    print name
    id = 121333445500000
    id += 1
    print id
    mac = "aa:bb:cc:dd:"
    ee = 0
    for j in range(0,9):
        ee1 = '0'+str(ee + j)+':'
        ff = 0

        for k in range(0,10):
            ff1 = ff+k
            if ff1 &lt; 10:
               mac1 = mac + ee1 + '0' + str(ff1)
               print mac1

            else:
                mac1 = mac + ee1 + str(ff1)
                print mac1
</code></pre>

<p>Output: </p>

<pre><code>name1
121333445500001
aa:bb:cc:dd:00:00
aa:bb:cc:dd:00:01
aa:bb:cc:dd:00:02
aa:bb:cc:dd:00:03
aa:bb:cc:dd:00:04
aa:bb:cc:dd:00:05
aa:bb:cc:dd:00:06
aa:bb:cc:dd:00:07
aa:bb:cc:dd:00:08
aa:bb:cc:dd:00:09
aa:bb:cc:dd:01:00
aa:bb:cc:dd:01:01
aa:bb:cc:dd:01:02
aa:bb:cc:dd:01:03
aa:bb:cc:dd:01:04
aa:bb:cc:dd:01:05
aa:bb:cc:dd:01:06
aa:bb:cc:dd:01:07
aa:bb:cc:dd:01:08
aa:bb:cc:dd:01:09
aa:bb:cc:dd:02:00
aa:bb:cc:dd:02:01
aa:bb:cc:dd:02:02
aa:bb:cc:dd:02:03
aa:bb:cc:dd:02:04
aa:bb:cc:dd:02:05
aa:bb:cc:dd:02:06
aa:bb:cc:dd:02:07
aa:bb:cc:dd:02:08
aa:bb:cc:dd:02:09
aa:bb:cc:dd:03:00
aa:bb:cc:dd:03:01
aa:bb:cc:dd:03:02
aa:bb:cc:dd:03:03
aa:bb:cc:dd:03:04
aa:bb:cc:dd:03:05
aa:bb:cc:dd:03:06
aa:bb:cc:dd:03:07
aa:bb:cc:dd:03:08
aa:bb:cc:dd:03:09
aa:bb:cc:dd:04:00
aa:bb:cc:dd:04:01
aa:bb:cc:dd:04:02
aa:bb:cc:dd:04:03
aa:bb:cc:dd:04:04
aa:bb:cc:dd:04:05
aa:bb:cc:dd:04:06
aa:bb:cc:dd:04:07
aa:bb:cc:dd:04:08
aa:bb:cc:dd:04:09
aa:bb:cc:dd:05:00
aa:bb:cc:dd:05:01
aa:bb:cc:dd:05:02
aa:bb:cc:dd:05:03
aa:bb:cc:dd:05:04
aa:bb:cc:dd:05:05
aa:bb:cc:dd:05:06
aa:bb:cc:dd:05:07
aa:bb:cc:dd:05:08
aa:bb:cc:dd:05:09
aa:bb:cc:dd:06:00
aa:bb:cc:dd:06:01
aa:bb:cc:dd:06:02
aa:bb:cc:dd:06:03
aa:bb:cc:dd:06:04
aa:bb:cc:dd:06:05
aa:bb:cc:dd:06:06
aa:bb:cc:dd:06:07
aa:bb:cc:dd:06:08
aa:bb:cc:dd:06:09
aa:bb:cc:dd:07:00
aa:bb:cc:dd:07:01
aa:bb:cc:dd:07:02
aa:bb:cc:dd:07:03
aa:bb:cc:dd:07:04
aa:bb:cc:dd:07:05
aa:bb:cc:dd:07:06
aa:bb:cc:dd:07:07
aa:bb:cc:dd:07:08
aa:bb:cc:dd:07:09
aa:bb:cc:dd:08:00
aa:bb:cc:dd:08:01
aa:bb:cc:dd:08:02
aa:bb:cc:dd:08:03
aa:bb:cc:dd:08:04
aa:bb:cc:dd:08:05
aa:bb:cc:dd:08:06
aa:bb:cc:dd:08:07
aa:bb:cc:dd:08:08
aa:bb:cc:dd:08:09
name2
121333445500001
aa:bb:cc:dd:00:00
aa:bb:cc:dd:00:01
aa:bb:cc:dd:00:02
aa:bb:cc:dd:00:03
aa:bb:cc:dd:00:04
aa:bb:cc:dd:00:05
aa:bb:cc:dd:00:06
aa:bb:cc:dd:00:07
aa:bb:cc:dd:00:08
aa:bb:cc:dd:00:09
aa:bb:cc:dd:01:00
aa:bb:cc:dd:01:01
aa:bb:cc:dd:01:02
aa:bb:cc:dd:01:03
aa:bb:cc:dd:01:04
aa:bb:cc:dd:01:05
aa:bb:cc:dd:01:06
aa:bb:cc:dd:01:07
aa:bb:cc:dd:01:08
aa:bb:cc:dd:01:09
aa:bb:cc:dd:02:00
aa:bb:cc:dd:02:01
aa:bb:cc:dd:02:02
aa:bb:cc:dd:02:03
aa:bb:cc:dd:02:04
aa:bb:cc:dd:02:05
aa:bb:cc:dd:02:06
aa:bb:cc:dd:02:07
aa:bb:cc:dd:02:08
aa:bb:cc:dd:02:09
aa:bb:cc:dd:03:00
aa:bb:cc:dd:03:01
aa:bb:cc:dd:03:02
aa:bb:cc:dd:03:03
aa:bb:cc:dd:03:04
aa:bb:cc:dd:03:05
aa:bb:cc:dd:03:06
aa:bb:cc:dd:03:07
aa:bb:cc:dd:03:08
aa:bb:cc:dd:03:09
aa:bb:cc:dd:04:00
aa:bb:cc:dd:04:01
aa:bb:cc:dd:04:02
aa:bb:cc:dd:04:03
aa:bb:cc:dd:04:04
aa:bb:cc:dd:04:05
aa:bb:cc:dd:04:06
aa:bb:cc:dd:04:07
aa:bb:cc:dd:04:08
aa:bb:cc:dd:04:09
aa:bb:cc:dd:05:00
aa:bb:cc:dd:05:01
aa:bb:cc:dd:05:02
aa:bb:cc:dd:05:03
aa:bb:cc:dd:05:04
aa:bb:cc:dd:05:05
aa:bb:cc:dd:05:06
aa:bb:cc:dd:05:07
aa:bb:cc:dd:05:08
aa:bb:cc:dd:05:09
aa:bb:cc:dd:06:00
aa:bb:cc:dd:06:01
aa:bb:cc:dd:06:02
aa:bb:cc:dd:06:03
aa:bb:cc:dd:06:04
aa:bb:cc:dd:06:05
aa:bb:cc:dd:06:06
aa:bb:cc:dd:06:07
aa:bb:cc:dd:06:08
aa:bb:cc:dd:06:09
aa:bb:cc:dd:07:00
aa:bb:cc:dd:07:01
aa:bb:cc:dd:07:02
aa:bb:cc:dd:07:03
aa:bb:cc:dd:07:04
aa:bb:cc:dd:07:05
aa:bb:cc:dd:07:06
aa:bb:cc:dd:07:07
aa:bb:cc:dd:07:08
aa:bb:cc:dd:07:09
aa:bb:cc:dd:08:00
aa:bb:cc:dd:08:01
aa:bb:cc:dd:08:02
aa:bb:cc:dd:08:03
aa:bb:cc:dd:08:04
aa:bb:cc:dd:08:05
aa:bb:cc:dd:08:06
aa:bb:cc:dd:08:07
aa:bb:cc:dd:08:08
aa:bb:cc:dd:08:09
name3
121333445500001
</code></pre>

<p>Try this code</p>

<pre><code>import time, random

mac = "aa:bb:cc:dd:"

for i in range(1,100):
    name = 'name'+ str(i)
    # getting random number for id
    id = int(time.time()) + random.randrange(0, 100, 1)

    # quotient in part 1
    mac_end1 = "0"  + str(int(i/10))
    # remainder in part 2
    mac_end2 = "0" + str(int(i%10))

    mac1 = mac + mac_end1 + ":" + mac_end2         
    print name, id, mac1
</code></pre>

python