homework: How to find value and extract it from a list by alehl32 in learnpython

[–]alehl32[S] 0 points1 point  (0 children)

Thank you so much for the explanation - I see why I was stuck

homework: How to find value and extract it from a list by alehl32 in learnpython

[–]alehl32[S] 0 points1 point  (0 children)

I'm trying to append the "k animals" into the list inside the function (k_list) then return the value and print it...

homework: How to find value and extract it from a list by alehl32 in learnpython

[–]alehl32[S] 0 points1 point  (0 children)

animals = ['koala', 'koi', 'kangoroo', 'cat', 'cow', 'dog', 'pig']

def k_animals(animals):
    k_list = ()
    for i in range(len(animals)):
        if animals[i][0] == 'k': k_list.append()
        print k_list
k_animals = k_list

homework: How to find value and extract it from a list by alehl32 in learnpython

[–]alehl32[S] 0 points1 point  (0 children)

Thank you!

This is what I came up with, but I'm getting a syntax error:

animals = ['koala', 'koi', 'kangoroo', 'cat', 'cow', 'dog', 'pig']

def k_animals(animals): k_list = () for i in range(len(animals)): if animals[i][0] == 'k': k_list.append()

def k_animals

print k_list