-2

My python code Output

I have used pydroid3 in my mobile and I couldn't get why null values also satisfies the if condition.

I Just pressed the enter button.

1 Answers1

2

input function returns a string, so if you're not entering anything, it does not return a null value, it returns an empty string ''. You can check this via:

'' == input()

And you'll see that an empty string satisfies your condition via:

'' in 'Yy'

Which evaluates to True

mtraceur
  • 3,254
  • 24
  • 33
dm2
  • 4,053
  • 3
  • 17
  • 28