0

Need explanation for simple program | assertion

the program is def a(x): x+=1 assert (x>=0),'negative' print(a(10)) output is: >>> None >>> but I expect out is < 11 > some one please explain how the out is came 'None' what is the meaning of 'None'

2nd Dec 2020, 11:35 AM
Antony Praveenkumar M
Antony Praveenkumar M - avatar
2 ответов
+ 3
None is same as null,Nil in other programming language. In python function that doesn't return anything always returns None . assert is used here to raise assertion error if x is less than 0 .
2nd Dec 2020, 11:44 AM
TOLUENE
TOLUENE - avatar
0
This function doesn't return any value. None is returned in such cases. None represents absence of value.
2nd Dec 2020, 11:43 AM
abhinav
abhinav - avatar