I want this function to print True if 200 occurs 3 times in a row. False otherwise.
def aList(n):
if n.count(200) >= 3:
return True
else:
return False
print(aList([100, 200, 200, 300, 200]))
Currently it is returning True because 200 exists 3 or more times, however it should return False because it is not occurring in a row.
Edit: Even if I iterate over the list, how can I pull True if the occurrence happens x amount of times.
for i in range(len(n)):
if i == 200:
return True
else:
return False