Search code examples
python-3.xlistuppercase

String not changing to uppercase


I would like to know why am I not getting the desired output ? my code -

𝚖𝚢𝚕𝚒𝚜𝚝 = ['𝚏𝚛𝚎𝚎', '𝚌𝚘𝚍𝚎𝚌𝚊𝚖𝚙']
for i in 𝚖𝚢𝚕𝚒𝚜𝚝:
  print(i.upper())
print(𝚖𝚢𝚕𝚒𝚜𝚝)

OUTPUT -

𝚏𝚛𝚎𝚎
𝚌𝚘𝚍𝚎𝚌𝚊𝚖𝚙
['𝚏𝚛𝚎𝚎', '𝚌𝚘𝚍𝚎𝚌𝚊𝚖𝚙']

Desired OUTPUT -

FREE
CODECAMP
['𝚏𝚛𝚎𝚎', '𝚌𝚘𝚍𝚎𝚌𝚊𝚖𝚙']

Solution

  • Your words are written in the mathematical monospace font for which there are no upper-case letters:

    hex(ord(mylist[0][0]))
    #'0x1d68f'
    hex(ord('f'))
    #'0x66' - this is the "normal f"
    mylist[0][0] == 'f'
    # False
    

    So, technically everything works: i.upper() converts i to the upper case, but since there are no upper-case letters, the result of the conversion is the same string.