List+Functions


#1

def fizz_count(x):
count=0
for count in x:
count=count+1
return count

keeps saying return is outside of the function


#2

Is there something wrong with my code?


#3

As you can see your return is indead outside your function.

Simply put it inside your function with correct indentation.

def fizz_count(x):
    count=0
    for count in x:
        # count=count+1 this should be as follows
        count += 1
    return count

#4

can anybody plz tell what exactly we r doing in this code?


#5

Please help!
What is wrong with my code?

def fizz_count(x):
count=0
for count in x:
if item='fizz':
item=count+1

return count

#6

The following worked for me
def fizz_count(x):
count=0
for item in x:
if item == "fizz":
count=count+1
return count
fizz_count (["cola", "icefizz", "pepsi", "pepsifizz"])


#8

you should use if function.cause it gives us a condition to make
here is my code but stiil givin an error
def fizz_count(x):
count=0
for item in x:
if item == "fizz":
count=count+1
return count