S
S
szlachcic2020-08-22 14:04:01
Python
szlachcic, 2020-08-22 14:04:01

Misunderstanding with if?

hello
, I’m learning Python, I’m trying to solve problems on codewars, I
ran into a misunderstanding: on the course, 80% of the if () option: is not used, however, in turn, the usual if is used much more often and also works.
when solving problems, codevars swears at the absence of ():, although in some solutions the pure if option works

the question: for what situations are both options used and what does their writing depend on?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Karbivnichy, 2020-08-22
@szlachcic

if waste
can you provide both examples.
for what situations are both options used and what determines their spelling?
It's written in Python books. For example, search for "Mark Lutz - Learning Python".
And if you don’t want to read books, then you will ask questions here for each line of code.
Python if( ): vs if:

D
Dr. Bacon, 2020-08-22
@bacon

1. correct if условие:
2. parentheses are needed to group expressions, if required
3. we are too lazy to guess what is wrong with you, show a specific example and a specific error

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question