Python string upper














































Python string upper



Python String : upper()


This article demonstrates how to use of upper() method in string.

The string upper() method converts all lowercase characters in a string into uppercase characters and returns it.


Syntax :

string.upper()


Parameter Values :

The upper() doesn't take any parameters.

Returns :

The upper() method returns the uppercased string from the given string. It converts all lowecase characters to uppercase.

If no lowercase characters exist, it returns the original string.



Sample Code :

1.
# example string
string = "this should be uppercase!"
print(string.upper())

# string with numbers
# all alphabets whould be lowercase
string = "Th!s Sh0uLd B3 uPp3rCas3!"
print(string.upper())
Output :
THIS SHOULD BE UPPERCASE!
TH!S SH0ULD B3 UPP3RCAS3!

2.
# first string
firstString = "python is awesome!"

# second string
secondString = "PyThOn Is AwEsOmE!"

if(firstString.upper() == secondString.upper()):
    print("The strings are same.")
else:
    print("The strings are not same.")
Output :
The strings are same.


Hence,we can see above function upper() converts lowercase letters in string to uppercase.


**********END OF ARTICLE **********


More Articles of Vishal Lodhi:

Name Views Likes
Python string zfill 114 0
Python string swapcase 92 0
Python string title 96 0
Python string startswith 102 0
Python string replace 143 0
Python string translate 84 0
Python string rpartition 85 0
Python string partition 74 0
Python string splitlines 113 0
Python string rsplit 79 0
Python string split 75 0
Python string rindex 81 0
Python string rfind 106 0
Python string upper 80 0
Python string lower 81 0
Python string maketrans 90 0
Python string strip 80 0
Python string rstrip 91 0
Python string lstrip 79 0
Python string rjust 96 0
Python string ljust 95 0
Python string len 81 0
Python string join 75 0
Python string casefold 82 0
Python string isprintable 84 0
Python string encode 78 0
Python string isdecimal 84 0
Python string isidentifier 77 0
Python string isupper 77 0
Python string istitle 79 0
Python string isspace 99 0
Python string isnumeric 101 0
Python string isdigit 82 0
Python string islower 84 0
Python string isalpha 95 0
Python string isalnum 101 0
Python string index 87 0
Python string find 93 0
Python string expandtabs() 80 0
Python string endswith 91 0
Python string count 85 0
Python string capitalize 77 0
Python string center 84 0
Python string Introduction 98 0
Python string Template 139 0
Python string Formatter 144 0
Python string printable 199 0
Python string whitespace 145 0
Python string punctuation 103 0
Python string octdigits 86 0
Python string hexdigits 103 0
Python string digits 79 0
Python string ascii_letters 344 0
Python string ascii_lowercase 146 0
Python string ascii_uppercase 156 0
How to Create Download Manager in Python 523 0
Python random weibullvariate 164 0
python random paretovariate 133 0
Python random vonmisesvariate 178 0
Python random normalvariate 195 0
Python random lognormvariate 119 0
Python random gauss 120 0
Python random gammavariate 131 0
Python random expovariate 193 0
Python random betavariate 184 0
Python random triangular 116 0
Python random uniform 140 0
Python random random 116 0
Python random sample 182 0
Python random shuffle 178 0
Python random choices 234 0
Python random choice 165 0
Python random randint 148 0
Python random randrange 213 0
Python random getrandbits 140 0
Python random setstate 136 0
Python random getstate 178 0
Python random seed 168 1
Python random Introduction 175 0

Comments