I know this is question is answered but I still need help with List and Functions at A Day at The Supermarket



returns wrong value. Python says should have returned more "List" than I actually have in key.
last change I made in code below say it returned 1 instead of 2

# Write your function below!
def fizz_count(x):                  #is x above the same as the X ["string list] below?
    for item in x:                     # So I can create the variable item to look in x[]?
        if item =="fizz":
            return count
print fizz_count
                                                            #is this why x is in fizz_count(x) so it can be passed?
                                                         # if x in fizz_count(y) would my list have to be y=["""""]?'''


x is defined as the local list, which we pass to the function:

print fizz_count(["fizz","Fizz","a","B"])


ok I feel stupid.
If I type print fizz_count(x) I get Traceback (most recent call last):
File "python", line 9, in
NameError: name 'x' is not defined

x is the variable that fiz_count () is looking for right?


def fizz_count(x):
    # code
    return count

print fizz_count(["fizz","Fizz","a","B"])


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.