Sorry if this is a simple question. I am new to Python. I am trying to write a function that will detect if there are 2 consecutive 2's next to each other. nums is a random array of ints. However, I'm getting an error that says list out of range. Can anyone tell me why this is? Thanks!
def has22(nums):
for ii in nums:
if nums[ii]==2:
if ii+1 < len(nums):
if ii+1 == 2:
return True
return False