+ 5

What is wronh in this code: def my_func(x); assert x>0, "error" print(x) my_func(-1)

16th Jan 2019, 2:06 PM
Anonymous....
Anonymous.... - avatar
3 Réponses
+ 6
You placed a semicolon at the end of the line where the "my_func" function was declared, IIRC you should place a colon there instead: It should be ... def my_func(x): Instead of ... def my_func(x);
16th Jan 2019, 2:36 PM
Ipang
+ 1
The second time you do my_func() you might want to do x-1 instead of just -1, since -1 < 0 while x-1 loops until x <= 0
16th Jan 2019, 2:10 PM
Roel
Roel - avatar
+ 1
Okk
16th Jan 2019, 2:11 PM
Anonymous....
Anonymous.... - avatar