Last active
March 31, 2024 20:39
-
-
Save pointofpresence/201e106e464fc4cff2db4ddea9a1f723 to your computer and use it in GitHub Desktop.
Python: Удалить словарь из списка по значению ключа
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Удалить словарь из списка: | |
thelist[:] = [d for d in thelist if d.get('id') != 2] | |
# Используя синтаксис thelist[:], мы можем сохранить ссылку на исходный список и избежать создания нового списка. | |
# Это может быть полезно, если переменная thelist уже используется в других частях кода, и вы хотите обновить ее содержимое. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment