print uppercase python code example
Example 1: capitalize string python
# Python string capitalization
string = "this isn't a #Standard Sntence."
string.capitalize() # "This isn't a #standard sentence."
string.upper() # "THIS ISN'T A #STANDARD SENTENCE."
string.lower() # "this isn't a #standard sentence."
string.title() # "This Isn'T A #Standard Sentence."
# ---------- Alternate Title Case ----------
# "This Isn't A #standard Sentence."
from string import capwords
string = capwords(string) # capitalize characters after each separator.
# see the doc: string.capwords(s, sep=None), separator defaults to space
# or implement it directly:
string = " ".join(s.capitalize() for s in string.split())
#
Example 2: how to change a string to small letter in python
my_str = "Hello World"
my_str.lower()
print(my_str)
Example 3: python to uppercase
text = "Random String"
text = text.upper() #Can also do
text = upper(text)
print(text)
>> "RANDOM STRING"
Example 4: uppercase string python
string.lower()
string.upper()
Example 5: python convert string to lowercase
# By Alan W. Smith and Petar Ivanov
s = "Kilometer"
print(s.lower())
Example 6: python to uppercase
original = Hello, World!
#both of these work
upper = original.upper()
upper = upper(original)