Похожие чаты

What does Python interpreter interprets when the IF statement doesn’t

have any expression or condition? I tot IF statement must have expression or condition?

17 ответов

12 просмотров

What are you referring to? It's if requested_toppings

it's going to check if the object is empty or not.

CH- Автор вопроса
4C
What are you referring to? It's if requested_toppi...

That’s why I’m having doubts on that… I thought IF statement must have either expression or condition then only it will execute

CH- Автор вопроса
Gian
it's going to check if the object is empty or not.

Yes… But then the IF statement doesn’t have any condition or expression?

CH- Автор вопроса
Gian
the expression is implicit.

I see… So in this case, it can be written as if len (requested_toppings) == 0:?

CH
I see… So in this case, it can be written as if le...

yes, in this example where you're using a list.

CH- Автор вопроса
Gian
the expression is implicit.

And in what circumstances, we will use implicit expression?

CH
And in what circumstances, we will use implicit ex...

For boolean: instead if if variable == True, you can use just if variable For int: instead of if variable != 0, you can just use if variable (any value different than zero, including negative) For str: instead of if variable != '', you can just if variable And so on. This also works for objects. Basically, if anything isn't None, it will trigger.

CH- Автор вопроса
Gian
For boolean: instead if if variable == True, you c...

Yes I’m aware of For Boolean… Is it it’s just same as while True then the loops will loop infinitely without assign it to a variable?

CH- Автор вопроса
Gian
For boolean: instead if if variable == True, you c...

Thanks for the explanation above 👆… Where can I read up in details on this?

CH
Thanks for the explanation above 👆… Where can I re...

Python docs, on the operators and expressions part, iirc

CH- Автор вопроса
Gian
Python docs, on the operators and expressions part...

I couldn’t find it at https://docs.python.org/3/

Gian
it's going to check if the object is empty or not.

Yes, more explicitly it checks the truthy value of the variable, in this case the truthy value of an empty list is false

CH- Автор вопроса

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта