*Memos:
- My post explains a string.
upper() can make a string uppercase for very caseless matching as shown below:
*Memos:
- It has no arguments.
- The German Alphabet
ẞ
(ß
) is used after a long vowel or dipthong, like inStraße
orbeißen
. - The German Alphabets
SS
(ss
) are used after a short vowel sound, like inFluss
orKuss
.
v = 'hElLo WoRlD'
print(v.upper())
# HELLO WORLD
v = 'ß' # Lowercase German Alphabet
print(v.upper()) # SS
v = 'ẞ' # Uppercase German Alphabet
print(v.upper()) # ẞ
lower() can make a string lowercase for normal caseless matching as shown below. *It has no arguments.
v = 'hElLo WoRlD'
print(v.lower())
# hello world
v = 'ß' # Lowercase German Alphabet
print(v.lower()) # ß
v = 'ẞ' # Uppercase German Alphabet
print(v.lower()) # ß
casefold() can make a string lowercase for very caseless matching as shown below. *It has no arguments:
v = 'hElLo WoRlD'
print(v.casefold())
# hello world
v = 'ß' # Lowercase German Alphabet
print(v.casefold()) # ss
v = 'ẞ' # Uppercase German Alphabet
print(v.casefold()) # ss
swapcase() can swap the case of each character of a string from uppercase to lowercase and from lowercase to uppercasee as shown below. *It has no arguments:
v = 'hElLo WoRlD'
print(v.swapcase()) # HeLlO wOrLd
v = 'ß' # Lowercase German Alphabet
print(v.swapcase()) # SS
v = 'ẞ' # Uppercase German Alphabet
print(v.swapcase()) # ß
title() can make a string titlecased as shown below. *It has no arguments:
v = 'hElLo WoRlD'
print(v.title()) # Hello World
v = 'ß' # Lowercase German Alphabet
print(v.title()) # Ss
v = 'ẞ' # Uppercase German Alphabet
print(v.title()) # ẞ
capitalize() can capitalize a string as shown below. *It has no arguments:
v = 'hello world'
print(v.capitalize())
# Hello world
isupper() can check if a string is uppercase and isn't empty as shown below. *It has no arguments:
print('PYTHON 3'.isupper())
# True
print('PYthON 3'.isupper())
print(''.isupper())
# False
islower() can check if a string is lowercase and isn't empty as shown below. *It has no arguments:
print('python 3'.islower())
# True
print('pyTHon 3'.islower())
print(''.islower())
# False
istitle() can check if a string is titlecased and isn't empty as shown below. *It has no arguments:
print('Python3'.istitle())
print('Python 3'.istitle())
print('John Smith'.istitle())
print('Johnsmith'.istitle())
# True
print('JohnSmith'.istitle())
print('John smith'.istitle())
print('john Smith'.istitle())
print('JohN SmitH'.istitle())
print(''.istitle())
# False
Top comments (0)