[Tutor] exceptions problem
Dave Angel
davea at ieee.org
Sat Sep 11 19:59:19 CEST 2010
On 2:59 PM, Roelof Wobben wrote:
> <snip>
> Hello Bob,
>
> Oke, I try to fish.
>
> When I do
>
> x="a"
> y=nt(x)
> Then I get ValueError.
>
> When I do
>
> x= 1.2
> y=int(x)
> No exception is raised.
> But when I do then x = I get a false.
> When I now do float(x) - int(x) I get 1.2 - 1 =.2 and that's greater then 0
>
> Because one of the two is true the Raise is executed.
>
>
> x = -9
> y= int(x)
> No exception is raised.
> X =y is True.
> But float(x) - int(x) I get 0.0 and 0.0> 0 is False.
> Because x =y is True the Raise is executed.
>
> Are these the right conclusions ??
>
> Roelof
>
>
>
But in your original code, x was a string. raw_input() produces a
string, not a float. So the middle case is different than what you're
trying now.
DaveA
More information about the Tutor
mailing list