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?
python string uppercase
add a comment |
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?
python string uppercase
1
Easy tutorial on doing this: dreamsyssoft.com/python-scripting-tutorial/strings-tutorial.php
– Triton Man
Jan 15 '13 at 18:05
1
Related: How to convert string to lowercase in Python? :)
– Piotr Dobrogost
May 5 '13 at 14:09
add a comment |
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?
python string 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?
python string uppercase
python string uppercase
edited Mar 13 '13 at 11:01
Nope
20.2k73766
20.2k73766
asked Feb 13 '12 at 7:48
gadssgadss
7,3152978122
7,3152978122
1
Easy tutorial on doing this: dreamsyssoft.com/python-scripting-tutorial/strings-tutorial.php
– Triton Man
Jan 15 '13 at 18:05
1
Related: How to convert string to lowercase in Python? :)
– Piotr Dobrogost
May 5 '13 at 14:09
add a comment |
1
Easy tutorial on doing this: dreamsyssoft.com/python-scripting-tutorial/strings-tutorial.php
– Triton Man
Jan 15 '13 at 18:05
1
Related: How to convert string to lowercase in Python? :)
– Piotr Dobrogost
May 5 '13 at 14:09
1
1
Easy tutorial on doing this: dreamsyssoft.com/python-scripting-tutorial/strings-tutorial.php
– Triton Man
Jan 15 '13 at 18:05
Easy tutorial on doing this: dreamsyssoft.com/python-scripting-tutorial/strings-tutorial.php
– Triton Man
Jan 15 '13 at 18:05
1
1
Related: How to convert string to lowercase in Python? :)
– Piotr Dobrogost
May 5 '13 at 14:09
Related: How to convert string to lowercase in Python? :)
– Piotr Dobrogost
May 5 '13 at 14:09
add a comment |
6 Answers
6
active
oldest
votes
>>> s = 'sdsd'
>>> s.upper()
'SDSD'
See String Methods.
132
Also worth mentioningtitle()
,'abc def'.title()
will give youAbc Def
– Burhan Khalid
Jan 14 '14 at 12:34
7
@BurhanKhalid - sir, I wish I had seen your comment before. I could have saved the trouble writing that function myself. :P
– Harshil Pansare
Jun 11 '15 at 6:22
1
It works for char type as well. Thank you for your helpful answer.
– yves Baumes
Jan 16 '16 at 14:01
add a comment |
To get upper case version of a string you can use str.upper
:
s = 'sdsd'
s.upper()
#=> 'SDSD'
On the other hand string.ascii_uppercase
is a string containing all ASCII letters in upper case:
import string
string.ascii_uppercase
#=> 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
add a comment |
to make the string upper case -- just simply type
s.upper()
simple and easy! you can do the same to make it lower too
s.lower()
etc.
add a comment |
s = 'sdsd'
print (s.upper())
upper = raw_input('type in something lowercase.')
lower = raw_input('type in the same thing caps lock.')
print upper.upper()
print lower.lower()
8
Welcome to Stack Overflow @HCode! It is customary to add some commentary to your code.
– aliteralmind
Jul 16 '14 at 2:57
add a comment |
for making uppercase from lowercase to upper
just use
"string".upper()
where "string"
is your string that you want to convert uppercase
for this question concern it will like this:
s.upper()
for making lowercase from uppercase string
just use
"string".lower()
where "string"
is your string that you want to convert lowercase
for this question concern it will like this:
s.lower()
If you want to make your whole string variable use
s="sadf"
# sadf
s=s.upper()
# SADF
add a comment |
For questions on simple string manipulation the dir
built-in function comes in handy. It gives you, among others, a list of methods of the argument, e.g., dir(s)
returns a list containing upper
.
add a comment |
protected by Community♦ May 6 '15 at 13:15
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
6 Answers
6
active
oldest
votes
6 Answers
6
active
oldest
votes
active
oldest
votes
active
oldest
votes
>>> s = 'sdsd'
>>> s.upper()
'SDSD'
See String Methods.
132
Also worth mentioningtitle()
,'abc def'.title()
will give youAbc Def
– Burhan Khalid
Jan 14 '14 at 12:34
7
@BurhanKhalid - sir, I wish I had seen your comment before. I could have saved the trouble writing that function myself. :P
– Harshil Pansare
Jun 11 '15 at 6:22
1
It works for char type as well. Thank you for your helpful answer.
– yves Baumes
Jan 16 '16 at 14:01
add a comment |
>>> s = 'sdsd'
>>> s.upper()
'SDSD'
See String Methods.
132
Also worth mentioningtitle()
,'abc def'.title()
will give youAbc Def
– Burhan Khalid
Jan 14 '14 at 12:34
7
@BurhanKhalid - sir, I wish I had seen your comment before. I could have saved the trouble writing that function myself. :P
– Harshil Pansare
Jun 11 '15 at 6:22
1
It works for char type as well. Thank you for your helpful answer.
– yves Baumes
Jan 16 '16 at 14:01
add a comment |
>>> s = 'sdsd'
>>> s.upper()
'SDSD'
See String Methods.
>>> s = 'sdsd'
>>> s.upper()
'SDSD'
See String Methods.
edited Nov 20 '14 at 16:38
answered Feb 13 '12 at 7:51
Dan D.Dan D.
54k1079101
54k1079101
132
Also worth mentioningtitle()
,'abc def'.title()
will give youAbc Def
– Burhan Khalid
Jan 14 '14 at 12:34
7
@BurhanKhalid - sir, I wish I had seen your comment before. I could have saved the trouble writing that function myself. :P
– Harshil Pansare
Jun 11 '15 at 6:22
1
It works for char type as well. Thank you for your helpful answer.
– yves Baumes
Jan 16 '16 at 14:01
add a comment |
132
Also worth mentioningtitle()
,'abc def'.title()
will give youAbc Def
– Burhan Khalid
Jan 14 '14 at 12:34
7
@BurhanKhalid - sir, I wish I had seen your comment before. I could have saved the trouble writing that function myself. :P
– Harshil Pansare
Jun 11 '15 at 6:22
1
It works for char type as well. Thank you for your helpful answer.
– yves Baumes
Jan 16 '16 at 14:01
132
132
Also worth mentioning
title()
, 'abc def'.title()
will give you Abc Def
– Burhan Khalid
Jan 14 '14 at 12:34
Also worth mentioning
title()
, 'abc def'.title()
will give you Abc Def
– Burhan Khalid
Jan 14 '14 at 12:34
7
7
@BurhanKhalid - sir, I wish I had seen your comment before. I could have saved the trouble writing that function myself. :P
– Harshil Pansare
Jun 11 '15 at 6:22
@BurhanKhalid - sir, I wish I had seen your comment before. I could have saved the trouble writing that function myself. :P
– Harshil Pansare
Jun 11 '15 at 6:22
1
1
It works for char type as well. Thank you for your helpful answer.
– yves Baumes
Jan 16 '16 at 14:01
It works for char type as well. Thank you for your helpful answer.
– yves Baumes
Jan 16 '16 at 14:01
add a comment |
To get upper case version of a string you can use str.upper
:
s = 'sdsd'
s.upper()
#=> 'SDSD'
On the other hand string.ascii_uppercase
is a string containing all ASCII letters in upper case:
import string
string.ascii_uppercase
#=> 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
add a comment |
To get upper case version of a string you can use str.upper
:
s = 'sdsd'
s.upper()
#=> 'SDSD'
On the other hand string.ascii_uppercase
is a string containing all ASCII letters in upper case:
import string
string.ascii_uppercase
#=> 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
add a comment |
To get upper case version of a string you can use str.upper
:
s = 'sdsd'
s.upper()
#=> 'SDSD'
On the other hand string.ascii_uppercase
is a string containing all ASCII letters in upper case:
import string
string.ascii_uppercase
#=> 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
To get upper case version of a string you can use str.upper
:
s = 'sdsd'
s.upper()
#=> 'SDSD'
On the other hand string.ascii_uppercase
is a string containing all ASCII letters in upper case:
import string
string.ascii_uppercase
#=> 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
answered Feb 13 '12 at 7:56
KL-7KL-7
32.4k87571
32.4k87571
add a comment |
add a comment |
to make the string upper case -- just simply type
s.upper()
simple and easy! you can do the same to make it lower too
s.lower()
etc.
add a comment |
to make the string upper case -- just simply type
s.upper()
simple and easy! you can do the same to make it lower too
s.lower()
etc.
add a comment |
to make the string upper case -- just simply type
s.upper()
simple and easy! you can do the same to make it lower too
s.lower()
etc.
to make the string upper case -- just simply type
s.upper()
simple and easy! you can do the same to make it lower too
s.lower()
etc.
answered Jun 27 '16 at 15:50
Katie TKatie T
19114
19114
add a comment |
add a comment |
s = 'sdsd'
print (s.upper())
upper = raw_input('type in something lowercase.')
lower = raw_input('type in the same thing caps lock.')
print upper.upper()
print lower.lower()
8
Welcome to Stack Overflow @HCode! It is customary to add some commentary to your code.
– aliteralmind
Jul 16 '14 at 2:57
add a comment |
s = 'sdsd'
print (s.upper())
upper = raw_input('type in something lowercase.')
lower = raw_input('type in the same thing caps lock.')
print upper.upper()
print lower.lower()
8
Welcome to Stack Overflow @HCode! It is customary to add some commentary to your code.
– aliteralmind
Jul 16 '14 at 2:57
add a comment |
s = 'sdsd'
print (s.upper())
upper = raw_input('type in something lowercase.')
lower = raw_input('type in the same thing caps lock.')
print upper.upper()
print lower.lower()
s = 'sdsd'
print (s.upper())
upper = raw_input('type in something lowercase.')
lower = raw_input('type in the same thing caps lock.')
print upper.upper()
print lower.lower()
edited Oct 16 '17 at 11:11
Community♦
11
11
answered Jul 16 '14 at 0:49
H CODEH CODE
17912
17912
8
Welcome to Stack Overflow @HCode! It is customary to add some commentary to your code.
– aliteralmind
Jul 16 '14 at 2:57
add a comment |
8
Welcome to Stack Overflow @HCode! It is customary to add some commentary to your code.
– aliteralmind
Jul 16 '14 at 2:57
8
8
Welcome to Stack Overflow @HCode! It is customary to add some commentary to your code.
– aliteralmind
Jul 16 '14 at 2:57
Welcome to Stack Overflow @HCode! It is customary to add some commentary to your code.
– aliteralmind
Jul 16 '14 at 2:57
add a comment |
for making uppercase from lowercase to upper
just use
"string".upper()
where "string"
is your string that you want to convert uppercase
for this question concern it will like this:
s.upper()
for making lowercase from uppercase string
just use
"string".lower()
where "string"
is your string that you want to convert lowercase
for this question concern it will like this:
s.lower()
If you want to make your whole string variable use
s="sadf"
# sadf
s=s.upper()
# SADF
add a comment |
for making uppercase from lowercase to upper
just use
"string".upper()
where "string"
is your string that you want to convert uppercase
for this question concern it will like this:
s.upper()
for making lowercase from uppercase string
just use
"string".lower()
where "string"
is your string that you want to convert lowercase
for this question concern it will like this:
s.lower()
If you want to make your whole string variable use
s="sadf"
# sadf
s=s.upper()
# SADF
add a comment |
for making uppercase from lowercase to upper
just use
"string".upper()
where "string"
is your string that you want to convert uppercase
for this question concern it will like this:
s.upper()
for making lowercase from uppercase string
just use
"string".lower()
where "string"
is your string that you want to convert lowercase
for this question concern it will like this:
s.lower()
If you want to make your whole string variable use
s="sadf"
# sadf
s=s.upper()
# SADF
for making uppercase from lowercase to upper
just use
"string".upper()
where "string"
is your string that you want to convert uppercase
for this question concern it will like this:
s.upper()
for making lowercase from uppercase string
just use
"string".lower()
where "string"
is your string that you want to convert lowercase
for this question concern it will like this:
s.lower()
If you want to make your whole string variable use
s="sadf"
# sadf
s=s.upper()
# SADF
edited May 1 '18 at 5:56
Keyur Potdar
5,64451631
5,64451631
answered Sep 1 '16 at 16:36
Pawanvir singhPawanvir singh
178211
178211
add a comment |
add a comment |
For questions on simple string manipulation the dir
built-in function comes in handy. It gives you, among others, a list of methods of the argument, e.g., dir(s)
returns a list containing upper
.
add a comment |
For questions on simple string manipulation the dir
built-in function comes in handy. It gives you, among others, a list of methods of the argument, e.g., dir(s)
returns a list containing upper
.
add a comment |
For questions on simple string manipulation the dir
built-in function comes in handy. It gives you, among others, a list of methods of the argument, e.g., dir(s)
returns a list containing upper
.
For questions on simple string manipulation the dir
built-in function comes in handy. It gives you, among others, a list of methods of the argument, e.g., dir(s)
returns a list containing upper
.
answered Oct 15 '18 at 22:28
bartfrenkbartfrenk
3824
3824
add a comment |
add a comment |
protected by Community♦ May 6 '15 at 13:15
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
1
Easy tutorial on doing this: dreamsyssoft.com/python-scripting-tutorial/strings-tutorial.php
– Triton Man
Jan 15 '13 at 18:05
1
Related: How to convert string to lowercase in Python? :)
– Piotr Dobrogost
May 5 '13 at 14:09