for line in output.split('\n')[2:]: mac = line.split('|')[0].strip().split() print('{:0>2}:{:0>2}:{:0>2}:{:0>2}:{:0>2}:{:0>2}'.format(*mac))