The isupper( ) Function is used to check if all the letters in the String are of upper case.
x = "Hello World" if x.isupper(): print("All the letters in the String are in upper case") else: print("Not all the letters in the String are in upper case")
In the above code, we have declared a String 'Hello World'.
So, to check, if all the letters in the String are of upper case, we have used 'isupper( )' function.
if x.isupper(): print("All the letters in the String are in upper case") else: print("Not all the letters in the String are in upper case")
And in this case, other than 'H' and 'W' in the String 'Hello World' all the other letters in the String are in lower case. So, we got the below output.
Similarly, let us look at the next example.
x = "HELLO WORLD" if x.isupper(): print("All the letters of the String are in upper case") else: print("Not all the letters of the String are in upper case")
In the above code, we have declared a String 'HELLO WORLD'.
Similarly, to check, if all the letters in the String are of upper case, we have used 'isupper( )' function.
if x.isupper(): print("All the letters of the String are in upper case") else: print("Not all the letters of the String are in upper case")
And in this case, all the letters in the String 'HELLO WORLD' are in upper case. So, we got the below output.