I've got a question that is to take a list of one or more ints 'nums' and returns True if the sequence [2, 4, 6]
appears in the list somewhere and False otherwise.
Here's my function so far:
def has246(nums):
num = ""
for i in nums:
num += str(i)
if "2" "4" "6" in num:
return True
else:
return False
For the following tests i get the expected result:
print(has246(\[2, 2, 4, 6, 2\]))
True
print(has246(\[2, 2, 4, 8, 2\]))
False
print(has246(\[2, 4\]))
False
But I get True for the following when the expected is False:
print(has246(\[24, 6\]))
False