161 - Solution
161 - Solution
Explanation
As you can see the error was fixed by simply implementing a try and except block.
When the get_selected_row function is called, Python will try to execute the
indented block under try . If there is an IndexError none of the lines under try will
be executed. Instead the line under except will be executed which is pass .
The pass stetement means do nothing. So the function will do nothing when there's
an empty listbox.
Browse Q&A
Continue