string
module in PythonThe string
module in Python is a collection of different constants.
ascii_uppercase
constantThe ascii_uppercase
constant in the string module contains the English letters from A to Z only in uppercase as a string.
The value of the constant is as follows:
ABCDEFGHIJKLMNOPQRSTUVWXYZ
string.ascii_uppercase
As ascii_uppercase
is a constant, we can access it via the string
module name.
import stringascii_uppercase_output = string.ascii_uppercaseprint("string.ascii_uppercase = '%s'" % (ascii_uppercase_output))
string
module.string. ascii_uppercase
in the ascii_uppercase_output
variable.ascii_uppercase_output
.import stringdef is_ascii_uppercase_only(str_input):for i in str_input:if i not in string.ascii_uppercase:return Falsereturn Truestr_to_check_1 = "ADFVERFDD"print("Does %s contains only ascii uppercase letters? %s" % (str_to_check_1, is_ascii_uppercase_only(str_to_check_1)))str_to_check_2 = "abji232daosfdgfRFDFD"print("Does %s contains only ascii uppercase letters? %s" % (str_to_check_2, is_ascii_uppercase_only(str_to_check_2)))
string
module.is_ascii_uppercase_only
that accepts a string as parameters and checks whether or not the input string contains only uppercase ASCII letters.str_to_check_1
containing only ASCII uppercase letters.is_ascii_uppercase_only
method passing str_to_check_1
as a parameter. Then, we display the results.str_to_check_2
containing lowercase and uppercase ASCII letters and digits.is_ascii_uppercase_only
method passing str_to_check_2
as a parameter. Then, we display the results.