Python Tip

Python_Dv's tweet image. Python Tip

I'm comfortable with match cases. For this tip, I would have used the anonymous function. getPrice = lambda food_item: { "Burger": 100, "Pizza": 200, "Juice": 50, "Tofu": 150 }.get(food_item, None)


Nice use of the dictionary! You can even load items from a file later with minimal changes.


This post is unavailable.

Hmm but I don’t think so let’s say u creating a huge object is u use this method u create all of them which consume so much time


Great tip! Python makes coding feel so much easier. Thanks for sharing!


Great use of a dictionary


United States Trends
Loading...

Something went wrong.


Something went wrong.