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 aplease 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 0 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. 1 gen = ["f", 'M', "female", "Male", "male", "F", "m", "m", "male", "Female", "x"] 2. 3 # Start your code below

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!