Nov-08-2019, 06:36 AM
(Nov-07-2019, 07:06 PM)newbieguy Wrote:Quote:There is no switch/case statement in Python. Use if/elif instead or a data structure. You did use a data structure, but I would do it this way:Yea I know it,I wanted to know way that is being similar like switch/case,because this is very useful option.
Do you understand that the values in the dictionary are functions? It turns out to be very useful to be able to store and pass around functions like you can with other values (ints, strings, etc.). For this specific example, one needn't write their own implementations of these functions if they don't want to - take a look at the
operator
module.