So, I have 3 possibilities of a list:
list_a = ['DU', "CARTE", 'AN', 'NM', 'DAN', 'DATE', '161', 'EUL', "Date", 'Latte', 'ZEBRA', 'M']
list_b = ['DU', "CARTE", 'AN', 'NM', 'DAN', 'DATE', '161', 'EUL', "Date", 'Latte', 'ZEBRA', 'F']
list_c = ['DU', "CARTE", 'AN', 'NM', 'DAN', 'DATE', '161', 'EUL', "Date", 'Latte', 'ZEBRA']
i.e. the list will either contain a 'M', a 'F' or it will not contain either of these 2. Also, if it contains 'M', it will not contain 'F' and vice versa! (they can be in any index position in list)
I have to find out, whether list contains 'M' or 'F' or not? If it does, I want it to assign/return what it contains - 'M','F' or None.
Currently I am doing:
for i in range(len(given_list)):
if given_list[i] == "M" or given_list[i] == "F":
answer = given_list[i]
break
I feel this can be done in a much better, pythonic way. Can anyone help me out on this?