I’m trying to create a function that outputs a list that only includes entries for members that are only 18 or over. My resulting list still outputs all members including those who are below the age of 18.
This is the list:
people = [('John', 36, 'M'),('Rachel', 24, 'F'),('Deardrie', 78, 'F'),('Ahmed', 17, 'M'),('Sienna', 14, 'F')]
This is the code that I tried:
def adults(members):
names = []
y= []
for entry in people:
if entry[1] >=18:
return (members)
else:
return none
I know that the solution is probably a simple one but I’m still quite new to Python, so it isn’t obvious to me yet. Any help would be greatly appreciated.
2