You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is an interesting use of a try/except statement to access a dictionary's values. Although I must admit that it's clever, I can't say I'm a fan. Beyond the scope of this course, you learn that a try/except statement is relatively costly in terms of efficiency compared to a simple if statement, especially when an exception is actually raised (as it is in this case many times). You should save such a statement for when it is necessary, and instead use built-in functions for dictionaries, such as .get() here.
The text was updated successfully, but these errors were encountered:
pwp-capstones/JoeKeepers_murder_mystery_program/murder_mystery_finished.ipynb
Lines 143 to 146 in ae45536
This is an interesting use of a try/except statement to access a dictionary's values. Although I must admit that it's clever, I can't say I'm a fan. Beyond the scope of this course, you learn that a try/except statement is relatively costly in terms of efficiency compared to a simple if statement, especially when an exception is actually raised (as it is in this case many times). You should save such a statement for when it is necessary, and instead use built-in functions for dictionaries, such as .get() here.
The text was updated successfully, but these errors were encountered: