Unit 5 Lesson Um dia no Supermercado / A day on market


#1

Escreva uma função chamada fizz_count que toma uma lista x como entrada.

Crie uma variável count para conter a contagem em andamento. Inicialize-a em zero.

Para (for) cada item em x:, se (if) esse item for igual à string "fizz" então incremente a variável count.
Depois do laço, retorne (return) a variável count.

What did I miss?

Function Below!

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


#2

you should put == instead of =


#3

@wizmarco, i have try this too.

that's the question:

Write a fizz_count call function that takes a list as input x .

Create a variable count to contain the count in progress. Initialize it to zero .

For (for ) each item x :, if ( if) this item is equal to the string " fizz " then increment the count variable.
After the loop , return ( return ) the count variable.

What i did wrong?


#4

if you did what I said, you only need to call the function def fizz_count() with a list that contain some sring includ "fizz" the list could be something like that.

my_list = ["fizz", "count", "fizz"]

#5

Escreva sua funcao abaixo!

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

error message:

File "python", line 6
if x == "fizz"
^
SyntaxError: invalid syntax


#6

Because its missing the : after the if condtion

if x == "fizz":

#7

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

Thanks!