In this video, I show 11 Tips and Tricks to Write Better Python code! I show a lot of best practices that improve your code by making your code much cleaner and more Pythonic.
All Tips:
- Iterate with enumerate instead or range(len(x))
- Use list comprehension instead of raw for loops
- Sort complex iterables with sorted()
- Store unique values with Sets
- Save memory with Generators
- Define default values in Dictionaries with .get() and .setdefault()
- Count hashable objects with collections.Counter
- Format strings with f-Strings (Python 3.6+)
- Concatenate strings with .join()
- Merge dictionaries with {**d1, **d2} (Python 3.5+)
- Simplify if-statements with if x in list
#python #programming #developer #machine-learning #web-development