![Convert mac address to colon win8](https://cdn2.cdnme.se/5447227/9-3/screenshot_4_64e629479606ee5be4b9a969.jpg)
![convert mac address to colon win8 convert mac address to colon win8](https://www.partitionwizard.com/images/uploads/articles/2019/09/how-to-find-mac-adress/how-to-find-mac-adress-2.png)
If I was writing this, however, I would probably do it in just a couple of lines, as you know exactly how the input and output strings are going to be formatted: def mac_conv(mac, sep='-'):
![convert mac address to colon win8 convert mac address to colon win8](https://benisnous.com/wp-content/uploads/2021/04/How-to-find-MAC-address-in-Ubuntu-800x445.jpg)
You can actually eliminate that usage of the variable all together: #join groups into a single MAC I would also avoid reusing variables, especially if its a function argument ( mac). #Open file with MAC addresses and convert them Return '.'.join(''.join(group) for group in groups)įirst of all, you should be using return rather than print to get a value out of a function, otherwise you'll have problems when you try to expand the program. This can result in: def mac_conv(mac, sep='-'): Other than the above function, you don't need to use f.readlines() you can just use f.
![convert mac address to colon win8 convert mac address to colon win8](https://www.cuehosting.com/blog/wp-content/uploads/2019/06/hggg-768x432.jpg)
I'd then join the last three lines into one.Īs return and '.'.join are easy to understand in a single one-liner.
![Convert mac address to colon win8](https://cdn2.cdnme.se/5447227/9-3/screenshot_4_64e629479606ee5be4b9a969.jpg)