Replies: 2 comments 3 replies
-
I think that the problem is because that this piece of code is part of a main (which is the process running under the notebook) so, the undefined variable error is raised by the master process not from the actual code you are running. def foo(a) -> object:
return (a + 3.45) < [1, 2, 3]
a = 1 # if commented Expression error
try:
foo(a)
except:
print("exception") If you run this, the try/except works fine. If you run the function |
Beta Was this translation helpful? Give feedback.
-
Now it works but with def, not works with fn def foo(a) -> object:
if a == 0:
print("zero")
elif a > 0 and a < 9 or a < 0:
print("small")
elif a >= 9:
print("big")
try:
a = "k"
foo(a)
except:
print("Something went wrong") |
Beta Was this translation helpful? Give feedback.
-
I would like to handle error with a message if the value passed to the function is not a number, but I get this error:
error: Expression [16]:38:29: use of unknown declaration 'a'
print(your_function(a))
Beta Was this translation helpful? Give feedback.
All reactions