#Snippet
Useful constants in #python
Using #Python's calendar module + the enumerate built-in to make a mapping of month names -> numbers
Useful constants in #python
Using #Python's calendar module + the enumerate built-in to make a mapping of month names -> numbers
>>> import calendar
>>> MONTH_NAMES_TO_NUMBERS = {
... v: k for k, v in enumerate(calendar.month_abbr[1:], start=1)
... }
>>> MONTH_NAMES_TO_NUMBERS
{'Jan': 1, 'Feb': 2, 'Mar': 3, 'Apr': 4, 'May': 5, 'Jun': 6, 'Jul': 7, 'Aug': 8, 'Sep': 9, 'Oct': 10, 'Nov': 11, 'Dec': 12}Forwarded from Information for IT Students
How to send a tweet with #Python and TweePy in under 10 lines of code
🐍🔥
For more information, refer the Twitter thread given below👇🏻
🐍🔥
For more information, refer the Twitter thread given below👇🏻
Invert binary tree in Python
Binary tree is a data structure and one of the simplest form of trees. You might have heard about people complaining that during interviews they are asked to invert a binary tree.
It may sound like something difficult, but this article shows a really simple solution using recursion.
https://bmwlog.pp.ua/invert-binary-tree-in-python/
Binary tree is a data structure and one of the simplest form of trees. You might have heard about people complaining that during interviews they are asked to invert a binary tree.
It may sound like something difficult, but this article shows a really simple solution using recursion.
https://bmwlog.pp.ua/invert-binary-tree-in-python/