-2

In Python, why a 'False' input entry via input function is being considered as a Truthy?

For e.g. in the below code block,

a_value = input('Enter the a value :')
b_value = input('Enter the b value :')
print('a_value =', bool(a_value))
print('b_value =', bool(b_value))

and the Output is,

Enter the a value :False
Enter the b value :False
a_value = True
b_value = True

as far as I understood, 'False' string is considered as 'Falsy'. Can someone explain why, please?

2 Answers2

1

as far as I understood, 'False' string is considered as 'Falsy'

No, the only falsy string is ''.

>>> bool('')
False
timgeb
  • 76,762
  • 20
  • 123
  • 145
0

Any non-empty string is considered truthy regardless of the contents; therefore, 'False' is a truthy value as observed.

TheMonarch
  • 397
  • 4
  • 11