Skip to content

Tag: python

Python Check if at least 1 item in a 2d list is None

Consider some 2d lists: How to check if there is at least one None in a 2d list? Outputs: deal with a should output a bool value False, and b should output True. I have no ideas when the list be a 2d list. Answer You can use two loops, one inside the other. This can be simplified by using

Why list([]) weighs less than []

I have such code: With the next result: The question is: Why does a list created with list([]) weigh less than a list created with just [] or for _ in condition? Answer (The details in this answer depend on the implementation, they are written to match CPython 3.10.0. Other versions or other implementations o…

Key compination at pygame

I’m using this python code https://gist.github.com/seankmartin/f660eff4787b586f94d5f678932bcd27#file-keyboardpress-py to get time for keyboard events. It’s working well, but I need to get KEYDOWN and KEYUP also for capital letters and exclamation point. So I modified it by adding to this part So n…