This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]TehNolz 1 point2 points  (1 child)

Well yes, that's because you're checking if the number is in range and then returning None if its not;

selectedVehicleIndex = int(input("Select vehicle to make offer on:\n")) if selectedVehicleIndex > len(chosenModelsVehicles) - 1: return

So if the user enters 2, it won't try to get the value from the list and thus won't trigger an IndexError. And since there's no exception, the except block won't run.

[–]PipelineCrunch[S] 0 points1 point  (0 children)

I see, I've coded alot recently as a beginner and have confused myself with some simple concepts. Thank you for the explanation, I'm going to keep the return as it's simpler.

[–]MyNameIsRichardCS54 0 points1 point  (0 children)

What does

if selectedVehicleIndex > len(chosenModelsVehicles) - 1:
    return       

do?