4.1.7 Changing Case: upper() and lower()

Unit: Unit 4: Strings, Lists, and Tuples • Interactive Practice

Quick Answer & Summary:

Interactive Python programming tutorial and practice in your browser.

Interactive Challenge (Run Live in Browser):

# Normalize user input for case-insensitive verification
user_command = "Quit"
headline = "python 3.12 introduces faster comprehension execution"

# 1. Convert to uppercase and lowercase
command_lower = user_command.lower()
command_upper = user_command.upper()

# 2. Case-insensitive equality check
is_exit_command = command_lower == "quit"

# 3. Title case headline
formatted_headline = headline.title()

print("Lowercase:", command_lower)
print("Uppercase:", command_upper)
print("Is Exit Command:", is_exit_command)
print("Title Case:", formatted_headline)
Open in Live Interactive Python Sandbox →