Search code examples
pythonmethodsuppercaselowercase

Python .upper and .lower methods returning no results


I'm having trouble getting Python's .upper and .lower methods to return anything. Here's the code:

initials = input("Enter your initials: ")
uppercase = initials.upper
print(uppercase)

What it returns is:

Enter your initials: mj
<built-in method upper of str object at 0x7f50734b01f0>

I originally integrated this into a larger function, but when I call uppercase later in the function the variable remains empty. I'm working in Google Colab.


Solution

  • To call a method in Python, you must open and close parenthesis after the name of the method:

    uppercase = initials.upper()
    

    See the example in the documentations of str.upper.