|
Can someone please tell me why was this marked incorrect? It's almost the same as the solution in the video. And it works for all the examples. Here is my code:
|
|
What if urls[0] happens to be the best URL? Although you iterate over the entire list, there's going to be no rank higher than the highest, so lucky_url won't get set, and you'll have an error. Your code only works if the best URL is at urls[1] or later. Probably the simplest change to make is changing the greater than to greater than or equal or to set lucky_url initially to urls[0]. |
|
Your code fails when the first entry has the highest rank as you initialize lucky_url in your if block, which will never be entered if the first url is the one with the highest rank, so when you return lucky_url, it will have no value assigned to it |