I have a list like this now.
gen = ["f", 'M', "female", "Male", "male", "F", "m", "m", "male", "Female", "x"]
As their may be different input formats, female may appear as "F", "f", "Female", or "female", and male may appear as "M", "m", "Male", or "male" in the list. How can we turn the list into a new gender list called "gen2" with only 0s and 1s, with 0 representing females, and 1 representing males. If there is any other elements in the list, just assume it as invalid and simply ignore it in the new list?
I tried this:
n=0
gen2=[]
for i in gen:
s=print(gen[n][0]==str.lower('F'))
if s is True:
gen2.append(0)
n=n+1
elif s is False:
gen2.append(1)
n=n+1
print(gen2)
and the expected output will be
[0, 1, 0, 1, 1, 0, 1, 1, 1, 0]