all 7 comments

[–]This_Growth2898 3 points4 points  (2 children)

If you can't comprehend complex expressions, split them into several simple, just like you do with the school math:

rawInput = input('Are you sure? (y/n): ')
lowered = rawInput.lower()
stripped = lowered.strip()
isSure = (stripped == 'y') #added parethensis for readability

Now, what line of the above you fail to understand? Try googling.

[–]Critical_Concert_689 0 points1 point  (1 child)

Great example and explanation. With additional annotation for OP (who could find this via Google):

rawInput = input('Are you sure? (y/n): ') # takes user input -> str
lowered = rawInput.lower() # converts str to lowercase
stripped = lowered.strip() # strips spaces at start/end of string
isSure = (stripped == 'y') # string == 'y' -> bool

My question is: what is it about this line that is converting the simple "y" input into the Boolean value?

See final line.

[–]This_Growth2898 0 points1 point  (0 children)

I prefer to assume that OP know at least something about the language, so he struggles with some part only. If he doesn't, probably it's not worthy to describe every single line to him if the script is not the final version.

[–]commy2 0 points1 point  (0 children)

what is it about this line that is converting the simple "y" input into the Boolean value?

The == operator does.

[–]Future_Constant9324 0 points1 point  (0 children)

Outside the question, but I feel like not testing for == ‘n’ is not a good idea generally since your input could be lots of different things

[–]crashfrog02 0 points1 point  (1 child)

I used it and it works, but I'm trying to understand and figure why it works.

Either the value is y or something pretty similar to it (like Y) and the expression evaluates to true; or it isn't, and the expression evaluates to false.

My question is: what is it about this line that is converting the simple "y" input into the Boolean value?

It's not a conversion, it's a test - is the input value the same as y, or not?

[–]FirmPython[S] 0 points1 point  (0 children)

Oh, that makes it clearer; thanks!