Question: I'm trying to match "header" to one of the header types in my ENUM class. I've tried header to match Header.PROFILE_NAME, Header.PROFILE_NAME.name, Header.PROFILE_NAME.name. However none of these worked so far. Can't find a lot of information about it either. Hope someone can help me out on this one. Cheers in advance. from enum import Enum class Header(Enum): PROFILE_NAME = None FIRSTNAME = None LASTNAME = None EMAIL = None PHONE = None STREET = None HOUSE = None ADDRESS2 = None CITY = None STATE = None COUNTRY = None CARD_TYPE = None CARD_NUMBER = None CARD_EXP_MONTH = None CARD_EXP_YEAR = None CARD_CVV = None   def setProfiles(): with open('profiles.csv', 'r') as profilesFile: profiles = csv.reader(profilesFile) # Sets CSV header name to index for index, profile in enumerate(profiles): if(index == 0): for index, header in enumerate(profile): match header: case Header.PROFILE_NAME.name: print("profile") #Header.PROFILE_NAME.value = index case Header.FIRSTNAME.name: print("firstn") #Header.FIRSTNAME.value = index case Header.LASTNAME.name: print("last") Header.LASTNAME._value_ = index case Header.EMAIL: Header.EMAIL._value_ = index case Header.PHONE: Header.PHONE._value_ = index case Header.STATE: Header.STATE._value_ = index case Header.HOUSE: Header.HOUSE._value_ = index case Header.ADDRESS2: Header.ADDRESS2._value_ = index case Header.CITY: Header.CITY._value_ = index case Header.STATE: Header.STATE._value_ = index case Header.COUNTRY: Header.COUNTRY._value_ = index case Header.CARD_TYPE: Header.CARD_TYPE._value_ = index case Header.CARD_NUMBER: Header.CARD_NUMBER._value_ = index case Header.CARD_EXP_MONTH: Header.CARD_EXP_MONTH._value_ = index case Header.CARD_EXP_YEAR: Header.CARD_EXP_YEAR._value_ = index case Header.CARD_CVV: Header.CARD_CVV._value_ = index # Creates profile and sets info else: #print(Header.PROFILE_NAME) # print(Header.FIRSTNAME) createProfile = Profile() for index, info in enumerate(profile): match index: case index if index == Header.PROFILE_NAME: createProfile.profileName = info case index if index == Header.FIRSTNAME: createProfile.firstName = info case index if index == Header.LASTNAME: createProfile.lastName = info case index if index == Header.EMAIL: createProfile.email = info case index if index == Header.PHONE: createProfile.phone = info case index if index == Header.STREET: createProfile.street = info case index if index == Header.HOUSE: createProfile.house = info case index if index == Header.ADDRESS2: createProfile.address2 = info case index if index == Header.CITY: createProfile.city = info case index if index == Header.STATE: createProfile.state = info case index if index == Header.COUNTRY: createProfile.country = info case index if index == Header.CARD_TYPE: createProfile.cardType = info case index if index == Header.CARD_NUMBER: createProfile.cardNumber = info case index if index == Header.CARD_EXP_MONTH: createProfile.cardExpiryMonth = info case index if index == Header.CARD_EXP_YEAR: createProfile.cardExpiryYear = info case index if index == Header.CARD_CVV: createProfile.cardCVV = info 

Answer: The match statement will work directly with enums, so convert your header into an enum first: for index, header in enumerate(profile): header = Header[header.upper()] # or whatever is needed to match the name match header: ...