Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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 belowStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started