Advertisement
basketcase

Normalize MAC Address

Aug 7th, 2011
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  1. mac=str('aA00CcA9e7Ff')
  2. maclen=len(mac)
  3. if maclen == 12:
  4.     maclist=list(mac)
  5.  
  6.     positions=2,5,8,11,14
  7.  
  8.     for i in positions:
  9.         maclist.insert(i,':')
  10.  
  11.     newmac=",".join(maclist)
  12.  
  13.     final12mac=newmac.replace(',','').lower()
  14.  
  15.     print final12mac
  16.    
  17. elif maclen == 17:
  18.     mac17final=mac.replace('-',':').lower()
  19.     print mac17final
  20. else:
  21.     print "There are only %s characters" % (maclen)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement