snippetpythonCriticalCanonical
How to change a string into uppercase?
Viewed 0 times
howuppercasechangestringinto
Problem
How can I convert a string into uppercase in Python?
When I tried to research the problem, I found something about
See How do I lowercase a string in Python? for the opposite.
When I tried to research the problem, I found something about
string.ascii_uppercase, but it couldn't solve the problem:>>> s = 'sdsd'
>>> s.ascii_uppercase
Traceback (most recent call last):
File "", line 1, in
AttributeError: 'str' object has no attribute 'ascii_uppercase'See How do I lowercase a string in Python? for the opposite.
Solution
Use
See String Methods.
str.upper():>>> s = 'sdsd'
>>> s.upper()
'SDSD'See String Methods.
Code Snippets
>>> s = 'sdsd'
>>> s.upper()
'SDSD'Context
Stack Overflow Q#9257094, score: 1343
Revisions (0)
No revisions yet.