Your True clause (when it prints "Valid Type") will only be True when all the following conditions are True :

Clearly these three things can't be True at the same time, so it executes the 'else' clause.

You wont get an error when you use isinstance - it simply returns False if the variable isn't the type you asked about.

There is a bug here - but it is in your code.

------ Original Message ------
From: "Yatharth Saini 9A" <>
Sent: Friday, 17 Dec, 21 At 16:14
Subject: [docs] Basic But Very Major Bug

I am a beginner, but still you must see this prob.
See this code:

If i will Put the value of X = 1,
it will show Not Valid! ,
At this moment python should show an error that , how can be the variable X , be int and float at the same time ,
But still it shows Not Valid!
I think it needs to be fixed to make python more intelligent language.

if isinstance(x, int) and isinstance(x, float) and x=='1':
print("Valid type!")
print("Not valid!")

docs mailing list --
To unsubscribe send an email to
Member address:

-- <br>Anthony Flury<br>