gadss gadss - 4 months ago 19
Python Question

How to change a string into uppercase

I have problem in changing a string into uppercase with Python. In my research, I got

string.ascii_uppercase
but it doesn't work.

The following code:

>>s = 'sdsd'
>>s.ascii_uppercase


Gives this error message:

Traceback (most recent call last):
File "<console>", line 1, in <module>
AttributeError: 'str' object has no attribute 'ascii_uppercase'


My question is: how can I convert a string into uppercase in Python?

Answer
>>> s = 'sdsd'
>>> s.upper()
'SDSD'

See String Methods.