Question: Given a list of ints, return True if the array contains a 3 next to a 3 somewhere.
Exp: has_33([1, 3, 3]) → True
My Code:
def has_33(nums):
for items in nums:
if items == 3:
if nums[nums.index(items)+1] == 3:
return True
else:
continue
return False
With this code I can't get get the answer I want. My answer I got now is: has_33([1, 3, 1, 3]) → False has_33([3, 1, 3]) → False has_33([3, 1, 3, 3]) → False #Even next to the "3" is "3" too.