Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
actually_a_dog
on March 10, 2022
|
parent
|
context
|
favorite
| on:
Python built-ins worth learning (2019)
Wouldn't it be easier to say
if numbers == []: print ("The numbers list is empty")
if your intent is to express "is the list empty?" in the condition?
sritchie
on March 10, 2022
[–]
That condition would fail on non-list sequences, like `numbers == (1,2,3)`; the `len` version makes the code more permissive.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: