A Day at the Supermarket: Lists and Functions


#1



Every time I enter my code, it says File "python", line 2
def fizz_count("fizz", "fizz", "fizz"):
^
SyntaxError: invalid syntax

I don't know what I'm doing wrong.

This is what my code looks like

def fizz_count("fizz", "fizz", "fizz"):
count=0
for item in fizz_count:
if item in fizz_count= "fizz":
count=count+1

    return count

`


#2

your function should have one parameter? A function parameter can't be a string

currently you have 3 parameters, which are all strings


#3

I changed it to this:

def fizz_count(x):
    
    count=0
for item in x:
    if item in x == "fizz":
        count==count+1
    return count
fizz_count("fizz", "cat", "fizz")

And it says that I put return outside of the function.


#4

this is currently your function + function content:

def fizz_count(x):
    
    count=0

the for loop is outside the function


#5

Thank you for helping. I appreciate it.


#6

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