I need to print a MAC address, with ':' tab, but I can only print the address with the tab for each string in the string, with the MAC address separating every 2 boxes.
I need to print a MAC address, with ':' tab, but I can only print the address with the tab for each string in the string, with the MAC address separating every 2 boxes.
If you are going to use .join
then this solution will answer you:
>>> ':'.join([addr[x-2:x] for x in range(2, len(addr)+2,2)])
'0a:1b:2c:3d:4e:5f'
If it's just for screen printing, you can try a simpler solution:
>>> addr='0a1b2c3d4e5f'
>>> '{0}{1}:{2}{3}:{4}{5}:{6}{7}:{8}{9}:{10}{11}'.format(*addr)
'0a:1b:2c:3d:4e:5f'