Convert to Uppercase
Convert entered text to uppercase with upper. Beginners follow a returned string value and learn which characters change and why the original text is unchanged.
1# Take string input2s = input("Enter a string: ")34# Convert to uppercase5upper_str = s.upper()6print(f"Uppercase: {upper_str}")
Output
Enter a string: Hello Uppercase: HELLO
In this one
- Call a string method
- Store a returned value
- Recognize Unicode case mappings
How it works
- 1
Read s.
- 2
Store s.upper() in upper_str.
- 3
Print that value without assigning through s.
Edge cases
Does empty input work?
Does empty input work?
Yes. upper returns an empty string.
Do digits become letters?
Do digits become letters?
No. They remain digits.
What's going on
s.upper() returns uppercase text; assigning it to upper_str keeps that result. It does not modify the original string object.
Ordinary lowercase English letters become uppercase while digits and punctuation remain. Unicode mappings can be more complex: some characters expand, so output length can change. No import or manual character-code arithmetic is needed for this built-in string method.
Does empty input work? Yes. upper returns an empty string.
Do digits become letters? No. They remain digits.
Quiz
Tap an option. The answer stays hidden until you pick.
Question 1
Why store upper_str?
Pick an answer to check it.
Question 2
Does empty input work?
Pick an answer to check it.
Questions people ask
Does empty input work?
Yes. upper returns an empty string.
Do digits become letters?
No. They remain digits.
Why store upper_str?
upper returns a new string.
๐Related Content
- ๐
Phase 5 - Learn Concepts
Review Phase 5 concepts and explanations
- ๐
Phase 5 - Quiz
Test your Phase 5 understanding with quiz questions
- ๐ป
Phase 5 - All Practice Problems
Explore all practice problems for Phase 5
- ๐
Master Your Logic Building - Complete Course
Browse all phases and tutorials
- ๐ง
Logic Building Overview
Learn about the complete logic building curriculum