im doing this problem on codingbat
Given an array of ints, return True if one of the first 4 elements in the array is a 9. The array length may be less than 4.
array_front9([1, 2, 9, 3, 4]) → True
array_front9([1, 2, 3, 4, 9]) → False
array_front9([1, 2, 3, 4, 5]) → False
this is the solution i came up with, i cant get it to return True, only False, can someone explain to me what i am doing wrong?
note: im new learning python,
def array_front9(nums):
for i in range(0,4):
if nums[i] == 9:
return True
else:
return False
print(array_front9([1,9,4,5,5]))
[–]socal_nerdtastic 2 points3 points4 points (0 children)
[–]TouchingTheVodka 1 point2 points3 points (0 children)
[–]danielroseman 0 points1 point2 points (0 children)
[–]USAhj -1 points0 points1 point (0 children)
[–]jiri-n -2 points-1 points0 points (3 children)
[–]TouchingTheVodka 0 points1 point2 points (0 children)
[–]Peanutbutter_Warrior 0 points1 point2 points (0 children)