Resolved: About Question 2
Hi,
I thought setting .lower() or .upper () specifies lower case or upper case of input words but the result didn't recognize any differences.
For example from the screenshot that I attached, I set word input to be only in upper case to write number in words between ONE to THREE to convert 1 to 3 as result.
However, when input ONE (upper case) and one (lower case) seperately, the result still shows 1. (which I was expected the result to be error if input word was one, for example)
Is there anyway we can make the result differentiate upper and lower case letter of the input words?
Hey Daniel,
Thank you for reaching out!
What the .upper()
function does is to convert all letter to capital ones. Therefore, "one" becomes "ONE" and "ONE" stays "ONE". The function .lower()
analogously converts all letters to lowercase. These functions are typically used to make sure all user inputs are unified. This means that a user that types "oNe" and another user that types "OnE" would both get the same output, namely "1".
To answer your question, Python is inherently a case sensitive language. If you comment out line 9 in your code, the if-else
statement will differentiate between lower- and uppercase characters. Therefore, typing "ONE" will output 1 and typing "one" would output "out of range".
Hope this helps!
Kind regards,
365 Hristina
Thank you Hristina,
I misunderstood the function of .upper() and .lower()