Last answered:

15 Dec 2022

Posted on:

15 Dec 2022

0

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,Question 2 screenshot for example)
Is there anyway we can make the result differentiate upper and lower case letter of the input words?

2 answers ( 1 marked as helpful)
Instructor
Posted on:

15 Dec 2022

0

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

Posted on:

15 Dec 2022

0

Thank you Hristina,
I misunderstood the function of .upper() and .lower()

Submit an answer