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)
0
0
0
0
100
Nice use of the dictionary! You can even load items from a file later with minimal changes.
0
0
0
0
139
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
0
0
0
0
84
Great tip! Python makes coding feel so much easier. Thanks for sharing!
0
0
0
0
9
United States Trends
- 1. #AEWDynamite 10.5K posts
- 2. #Survivor49 1,965 posts
- 3. #SistasOnBET N/A
- 4. #iubb 1,100 posts
- 5. Athena 10.7K posts
- 6. #ALLCAPS 1,163 posts
- 7. Binnington 1,061 posts
- 8. Ovechkin 4,730 posts
- 9. Harley 11.5K posts
- 10. Godzilla 27.3K posts
- 11. Savannah 4,946 posts
- 12. Mitchell Robinson N/A
- 13. Claudio 50.2K posts
- 14. Lamar Wilkerson N/A
- 15. Paige 28.2K posts
- 16. Unplanned 3,599 posts
- 17. Randle 2,815 posts
- 18. Breeze 24.5K posts
- 19. Cade 27.3K posts
- 20. Rickea N/A
Loading...
Something went wrong.
Something went wrong.