So far, I think I'm doing it right however it doesn't seem to generate the results I wanted.
def occurrence(e,List): for item in List: s = 0 if item == e: s += 1 return s
Basically I want my function to count how many times e occurs in List. So basically I can do something like:
However it seems like its not looping, and I'm assuming the loop stops after the first time "item" is "e".
So when I run the function I get
The biggest thing here I simplicity, I'm looking to get desired results simply with if, while, for, etc loops.
Edited 4 Years Ago by ProNewb