4 lessot


#1

Hi people, stuck on 4 lessons.
Help with the cycle please!
No errors, but still not correct

# Write your function belowx
def fizz_count(x):
  count = 0
  for item in x:
    if item == 'fizz':
      count = count + 1
      return count
    
  lotto = ["fizz","cat", "fizz"]
  small = fizz_count(lotto)
  print small

#2

why are lotto list and function call (which executes the function) within the function itself? That is confusing

also, by default, a function returns None at the end. If we want to return something else at the end of the function, we can use the return keyword

thus, the function ends when a return keyword is reached (given return is the last thing a function does)

so, your function ends when it finds its first fizz match (return is reached then), but what if there are multiple fizzes in the list?


#3

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