Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

.upper & .lower

This might be a dumb questions but what do .upper and .lower mean and what are they called? I feel like that was never covered.

1 Answer

upper is short for "Uppercase" and lower is short for "Lowercase".

They are what are called methods which are essentially functions that belong to a class. More specifically they are methods that belong to strings. Which means that you can use them on a string to perform some action on it.

The upper method takes a string and converts it to uppercase and lower converts it to lowercase. Example:

example = "Hello World!"

print(example.upper())
# Prints: "HELLO WORLD!"

print(example.lower())
# Prints: "hello world!"