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.
you should have handled array overflow
Not the best practice cuz any other type of n then int will return -1.
Didn't event think of catching errors on these fundamental tasks...I like it.
Not the best practice as any other errors that are not due to IndexErrors will still return -1. Its best to return -1 ONLY when index is out of range.
Got it. Thank you very much for your help!
Josh
hmm.. i think you need to get some undrstanding of pass by value / pass by reference in general. And how it works in python.
You can check something like this: https://www.geeksforgeeks.org/pass-by-reference-vs-value-in-python/
Hope you'll answer your own questions after this =)
I'm a little confused by array[n].
Isn't this used to look up in a list/dict?
array is a parameter. Don't we need to create a list first?
I'm new at this.
Thank you very much!
Josh
bare excepts are a good example of what not to do. So this is exactly NOT best practice.
I agree on both counts; catching exceptions is good and handling expected states is great.
In case of negative index it's definitely the best practice.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution