+ 2

Having a problem in Python Exceptions and files.

Hey ive decided to learn python lately and I got into Exceptions and files. I got to the raising Exceptions quizz and I got no idea how to solve it everything I'm trying its says wrong Evenn tried to run it in any code editor and I got it right but seems like solo learn didn't The Questions : num = input(":") if float(num) [I have to put something here] 0: raise ValueError("Negative!") Thanks in advance Liam.

24th Dec 2020, 10:38 PM
ליאם אטיאס
ליאם אטיאס - avatar
3 Réponses
+ 2
I think you are supposed to place the right logic operator. In your case, you need to raise an exception if a negative number is entered, so you have to check for it. "float(num) < 0"
24th Dec 2020, 10:58 PM
Apollo-Roboto
Apollo-Roboto - avatar
+ 2
Number with negative value means less than zero so here the condition to set in if statement .
24th Dec 2020, 10:59 PM
HBhZ_C
HBhZ_C - avatar
0
Thanks Apollo-Roboto. i used to do <= insted of just < Thanks!
25th Dec 2020, 12:02 AM
ליאם אטיאס
ליאם אטיאס - avatar