Write a function first_last6(nums) that takes a list of ints nums and returns True if 6 appears as either the first or last element in the list. The list will be of length 1 or more.
My code:
def first_last6(nums):
if nums[0] or nums[-1] == "6":
return True
else:
return False
It is not returning the right answer for this test:
print(first_last6([3, 2, 1]))
its suppose to be False
, while it prints True
.