Telegram Group & Telegram Channel
Что выведет этот код?

Реализация функции
all
эквивалентна этому:

def all(iterable):
for element in iterable:
if not element:
return False
return True

all([])
- True, потому что iterable пустой список и мы не заходим в цикл.

all([[]])
- False, потому что мы заходим в цикл и первый элемент iterable - пустой список, а
bool([]) = False

all([[[]]]) - True
, потому что первый элемент это уже не пустой список, а список в котором пустой список, т.е.
bool([[]]) = True



tg-me.com/pythrone/5
Create:
Last Update:

Что выведет этот код?

Реализация функции

all
эквивалентна этому:

def all(iterable):
for element in iterable:
if not element:
return False
return True

all([])
- True, потому что iterable пустой список и мы не заходим в цикл.

all([[]])
- False, потому что мы заходим в цикл и первый элемент iterable - пустой список, а
bool([]) = False

all([[[]]]) - True
, потому что первый элемент это уже не пустой список, а список в котором пустой список, т.е.
bool([[]]) = True

BY PyThrone




Share with your friend now:
tg-me.com/pythrone/5

View MORE
Open in Telegram


PyThrone Telegram | DID YOU KNOW?

Date: |

The S&P 500 slumped 1.8% on Monday and Tuesday, thanks to China Evergrande, the Chinese property company that looks like it is ready to default on its more-than $300 billion in debt. Cries of the next Lehman Brothers—or maybe the next Silverado?—echoed through the canyons of Wall Street as investors prepared for the worst.

The seemingly negative pandemic effects and resource/product shortages are encouraging and allowing organizations to innovate and change.The news of cash-rich organizations getting ready for the post-Covid growth economy is a sign of more than capital spending plans. Cash provides a cushion for risk-taking and a tool for growth.

PyThrone from tw


Telegram PyThrone
FROM USA