The main takeaway is the use of the dict in such scenario (i.e. instead of case construct available in other languages). The use of the tuple as a key is something particular to the current task - we need to use both height and width as key and because tuple is hashable, it can be used as key in dictionary.
Is there a better way to write this case scenario?
Is there a better way to write this case scenario?
|
|
Possibly Related Threads… | |||||
Thread | Author | Replies | Views | Last Post | |
Switch case or match case? | Frankduc | 9 | 4,886 |
Jan-20-2022, 01:56 PM Last Post: Frankduc |
|
Help: write 'case' with Python | ICanIBB | 2 | 1,960 |
Jan-27-2021, 09:39 PM Last Post: Larz60+ |
|
How to write switch case statement in Python | pyhelp | 9 | 9,619 |
Nov-11-2018, 08:53 PM Last Post: woooee |
Users browsing this thread: 1 Guest(s)