Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in Python by (47.6k points)

I have a problem with 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'

1 Answer

0 votes
by (106k points)
edited by

To convert a string into uppercase you can use str.upper() function:-

s = 'sdsd'

s.upper() 

image

We have another method to convert a string into an upper case which is string.ascii_uppercase is a string containing all ASCII letters in uppercase:

import string 

String.ascii_uppercase

image

To know more about this you can have a look at the following video tutorial:-

Related questions

0 votes
1 answer
0 votes
1 answer
+1 vote
2 answers

Browse Categories

...