I have been looking around for an answer to this and what I could find was you use the .upper()
command but this doesn't seem to work,
Example,
>>> x = a
>>>x.upper()
>>>print (x)
But what it displays is just the original.
I have been looking around for an answer to this and what I could find was you use the .upper()
command but this doesn't seem to work,
Example,
>>> x = a
>>>x.upper()
>>>print (x)
But what it displays is just the original.
The correct way to do it is
x = x.upper()
Python strings are immutable, so str.upper()
returns the result instead of changing the string in place (as do all other string manipulation functions).
x.upper()
does not modify x
; it just computes the new string, which you'd see if you printed x.upper()
. To retain that value, you could assign it back to x
.