Lists + Functions question- A day at the supermarket


#1

Somehow this code works, I'm pretty sure that it's supposed to return 2, but instead I got and still passed the lesson.

Not sure if bug or it's simply just correct

code:

def fizz_count(x):
    count = 0
    for word in x:
        if word == "fizz":
            count = count + 1
    return count
    
fizz_count(["fizz", "cat", "fizz"])
print fizz_count

if this is right, I would like an explanation because I just followed the example format but substituted other words in.
If it's a bug, well....I dunno

`


#2

a function call requires parentheses, between the parentheses supply an argument if needs be.


#3

now it will print "2" .u need to store value of "fizz_count(["fizz", "cat", "fizz"])" in any variable after doing thatif u will print that variable it will work fine....


#4

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