Lists+fuction


#1



Replace this line with your code. 

def fizz_count(lost):
    count=0
    for i in lost:
        if i=='fizz':
            count=+1
            
    return count
            
            
l=['fizz','fizz','cat','dog']
small=fizz_count(l)


#2

i ma not able to print exact how many times fizz appears.


#3

what is your question? what is the error you get?


#4

i want to print how many times the string fizz is repeated in the the list.
its showing the count value should be 4


#5

you store the result of the counting in small variable, so print small on the last line


#6

its printing 1.every time.


#7

did you add print small as last line of code? it should print 2, given fizz is twice in your list


#8

yaa.again its showing 1.


#9

oops, i missed that.

we can update a variable like this:

a = 5
a = a  + 5

we can also use a shorthand:

a = 5
a += 5

you use the shorthand, but incorrectly. you have =+, while it should be +=


#10

thanks bro.i got it.


#11

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