Asserts are like if? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 8

Asserts are like if?

you compare data and if is right continue and if not(else) raise an exception?

3rd May 2017, 7:04 PM
Guilherme Augusto De Sousa
Guilherme Augusto De Sousa - avatar
7 Respostas
+ 19
Kind of. Using assert supports debugging and yes, it works as if you check on a condition being True. If it is False, AssertionError() is raised.
3rd May 2017, 7:16 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 11
Seems like that. Only that there ainā€™t an ā€œelseā€ statement to execute. Either you go through and execute the next command or you land into an error.
22nd Sep 2018, 11:24 AM
āš”ļøPikachuāš”ļø
āš”ļøPikachuāš”ļø - avatar
+ 1
Thanks a lot
3rd May 2017, 7:55 PM
Guilherme Augusto De Sousa
Guilherme Augusto De Sousa - avatar
+ 1
Good question!
24th May 2017, 10:01 PM
Tamir Elsahy
Tamir Elsahy - avatar
0
I also had the same doubt!thanks.
26th Nov 2017, 6:56 AM
syedkabir
syedkabir - avatar
0
Use accerts in testing the code ... I have not seen accerts in production code .... some one can correct me if my assumption is wrong
22nd Feb 2018, 2:16 PM
cool
0
What I have seen is that asserts stop completely if anything turns out to be false.
11th Apr 2018, 6:58 PM
Ridwan Abrar
Ridwan Abrar - avatar