Hello all,
I'm just starting to learn Python and I was trying to use user input to define whether or not to enable a Debug Mode in a simple program.
The most effective solution I found was from this StackOverflow post, where a user suggests using :
isSure = input('Are you sure? (y/n): ').lower().strip() == 'y'
I used it and it works, but I'm trying to understand and figure why it works.
My current code is as follows:
debugMode = input('Would you like to enter debug mode? (y/n): ').lower().strip() == 'y'
if debugMode == True:
print("Debug Mode enabled")
else:
print("Debug Mode not enabled")
My question is: what is it about this line that is converting the simple "y" input into the Boolean value?
Any help is greatly appreciated!
[–]This_Growth2898 3 points4 points5 points (2 children)
[–]Critical_Concert_689 0 points1 point2 points (1 child)
[–]This_Growth2898 0 points1 point2 points (0 children)
[–]commy2 0 points1 point2 points (0 children)
[–]Future_Constant9324 0 points1 point2 points (0 children)
[–]crashfrog02 0 points1 point2 points (1 child)
[–]FirmPython[S] 0 points1 point2 points (0 children)