Question: please used in basic python language! thank you Assume you have a list of gender information as following. gen = [f, 'M', female, Male, male,
please used in basic python language! thank you
Assume you have a list of gender information as following. gen = ["f", 'M', "female", "Male", "male", "F", "m", "m", "male", "Female", "x"] Due to 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. Please turn the list into a new gender list called "gen2" with only Os and 1s, with O representing females, and 1 representing males. If there is any other elements in the list, we assume it as invalid and simply ignore it in our new list. Expected output: [0, 1, 0, 1, 1, 0, 1, 1, 1, 0] Noted that your program should be applicable when the values in the gen list change
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
