+ 1

What's wrong with the code , excepted output is true but it showing false.

def arrayCheck(nums): for i in range(len(nums)-2): if nums[i]==1 and nums[i+1]==2 and nums[i +2]==3: return True return False '''nums=[1,2,3,1] value=arrayCheck(nums) print(value) nums=[1,1,2,4,1] value=arrayCheck(nums) print(value)''' nums=[1,2,1,2,3] value=arrayCheck(nums) print(value)

21st Aug 2018, 8:02 PM
Bipul Kumar Singh
Bipul Kumar Singh - avatar
1 ответ
+ 4
`return False` should be outside of the `for` loop (same indentation level).
21st Aug 2018, 8:08 PM
Eduardo Petry
Eduardo Petry - avatar