Help with some code in Python 2
Go to solution
Solved by GhostHitWall,
Not sure if I understand you correctly but I think this is what you are asking.
def catego(lista):
l1=[]
for i in lista:
if i>=0 and i<=12:
l1.append("Niño")
elif i>12 and i<=17:
l1.append("Adolescente")
elif i>18 and i<=30:
l1.append("Joven")
elif i>30 and i<=45:
l1.append("Maduro")
elif i>45 and i<=65:
l1.append("Adulto")
else:
l1.append("Adulto Mayor")
return l1
Edades=[9,45,67,38,23,15,47]
print(catego(Edades))
The above code gives me output like this,
['Niño', 'Maduro', 'Adulto Mayor', 'Maduro', 'Joven', 'Adolescente', 'Adulto']
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now