error in the regex extraction

I am working on the python course with zaid so far i have reached the section on “Extracting a substring using Regex”
my code reads:
#!/usr/bin/env python

import subprocess
import optparse
import re

def get_arguments():
parser = optparse.OptionParser()
parser.add_option("-i", "--interface", dest="interface", help="interface to change its MAC address")
parser.add_option("-m", "--mac", dest="new_mac", help="New MAC address")
(options, arguments) = parser.parse_args()
if not options.interface:
    parser.error("[-] please specify an interface, use --help for more info")
elif not options.new_mac:
    parser.error("[-] please specify a MAC, use --help for more info")
return options

def change_mac(interface, new_mac):["sudo", "ifconfig", interface, "down"])["sudo", "ifconfig", interface, "hw", "ether", new_mac])["sudo", "ifconfig", interface, "up"])
print("[+] Changing MAC address for " + interface + " to " + new_mac)

options = get_arguments()
change_mac(options.interface, options.new_mac)

 ifconfig_result = subprocess.check_output(["ifconfig", options.interface])
mac_address_search_result ="\w\w:\w\w:\w\w:\w\w:\w\w", ifconfig_result)

as far as i can see in the tutorial this is how it is supposed to be but i am getting an error from the “” file as follows:
Traceback (most recent call last):
File “”, line 32, in
mac_address_search_result ="\w\w:\w\w:\w\w:\w\w:\w\w", ifconfig_result)
File “/usr/lib/python3.8/”, line 201, in search
return _compile(pattern, flags).search(string)
TypeError: cannot use a string pattern on a bytes-like object

i did look at some google posts about this type of error but i couldnt find anything of much use to the mac changer i am building from them mostly stuff to do with link extraction can anyone please see why this error is happening thanks in advanced.

I found my ERROR despite having looke several times well i missed the fact that now i notice that i had not coppied the code properly,
on line 32 i was missing a small piece like this
this simply made my error and unpredicable result
also on line 30 i needed to add to the end of the line


this is not in the tutorial video so maybe if possible can someone that know more about python3 explane for me why i needed to use this thanks in advance

There is a huge difference between python 2 and python 3. Python 2 considered both byte-string and normal string as equal but in python 3 these two are not equal that’s why we have to explicitly state the format

ah so the biggest part of my error will be coming from calling the file as python3

and i just found that within a couple of lectures that this explanation is fully explaned for me thanks @Apurv-StationX