Mai The Dung
Mai The Dung
Resume
999 Python Super Tips (1 → 7)
999 Python Super Tips (1 → 7)

999 Python Super Tips (1 → 7)

Tags
Python
Published
November 12, 2022
Author
Mai The Dung

1. “Else” condition inside a “for” loop

notion image

2. Get elements from a list using named variables

notion image

3. Get n largest or n smallest elements in a list using the module heapq

notion image

4. Pass values from a list as method arguments

notion image
This can be helpful in situations where we want to pass all elements of a list as method arguments:
notion image

5. Get all the elements in the middle of the list

notion image

6. Assign multiple variables in just one line

notion image

7. List comprehensions

notion image
We can do the same with dictionaries, sets, and generators.
notion image
Table of Contents
1. “Else” condition inside a “for” loop2. Get elements from a list using named variables3. Get n largest or n smallest elements in a list using the module heapq4. Pass values from a list as method arguments5. Get all the elements in the middle of the list6. Assign multiple variables in just one line7. List comprehensions
Copyright 2022 Mai The Dung