Ad
  • Custom User Avatar

    OP solved it, closing

  • Default User Avatar

    This is a textbook solution. However, remember that nothing past Return will execute so you might want to move up that print statement.

  • Custom User Avatar

    This error means that you're trying to loop through something you can't loop through, like
    for i in 8:
    doSomething()

    This doesn't makes sense, so Python gives you a TypeError. In this case, the simple problem is that the problem wants you to find how many xs are in xs, not the other way around! Switch your line to:
    def number_of_occurrences(xs, x):
    and you should be good.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution