Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
I agree with you, if he adds a negative number to the array, the code will give an erroneous value
the instructions say that "The numbers will also all be unique"
so you'll never get two of the same values, e.g. two '3's in your example
I do not think that this solution is correct.
It will overlook same-as items.
Try this variable with it.
numbers_list = [1, 2, 3, 3, 6, 7, 8, 9, 10, 12]
"3" would be the first non-consecutive item.
But the above function will choose "12"
The check should be whether it is consecutive (+1) or not.
range(1,len(arr) is to loop through array, starting from index 1 to the last index of array. why do you do this? because you need to check the condition from second index which is index 1 for example: arr[1] - arr[1-1] > 1: imagine if you start from index 0 if it will be like this arr[0] - arr[0-1] or arr[0] - arr[-1]
good looking out
You went for it
It is one of the best and simple solutions. Congrats!