temp = -10 assert (temp >= 0), "Colder than absolute zero!" | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

temp = -10 assert (temp >= 0), "Colder than absolute zero!"

Here why the second argument is not in the parentheses , why it is important to write outside the parentheses ?

21st Aug 2019, 4:37 PM
Rupal Raut
1 Answer
+ 4
assert is not a function, but a keyword, and they have their own syntax. You also don't need the first set of parentheses, it's enough to just write the expression, and then the error string. It's basically a shortcut for this: if temp < 0: raise AssertionError( 'Colder than absolute zero!' )
21st Aug 2019, 4:47 PM
HonFu
HonFu - avatar