Python String Methods

print("Hash Bang Code".capitalize()) # Hash bang code
print("Hash Bang Code".casefold()) # hash bang code
print("Hash Bang Code".swapcase()) # hASH bANG cODE
print("Hash Bang Code".encode()) # b'Hash Bang Code'
print("Hash Bang Code".center(18, "_")) # __Hash Bang Code__
print("Hash Bang Code".rjust(18, "_")) # ____Hash Bang Code
print("Hash Bang Code".ljust(18, "_")) # Hash Bang Code____
print("Hash {} Code".format("Bang")) # Hash Bang Code
print(" Hash Bang Code ".strip()) # Hash Bang Code

print("Hash Bang Code".istitle()) # True
print("Hash Bang Code".isupper()) # False
print("Hash Bang Code".isalnum()) # False
print("Hash Bang Code".isalpha()) # False
print("Hash Bang Code".isascii()) # True
print("Hash Bang Code".isdecimal()) # False
print("Hash Bang Code".isdigit()) # False
print("Hash Bang Code".isidentifier()) # False
print("Hash Bang Code".islower()) # False
print("Hash Bang Code".isnumeric()) # False
print("Hash Bang Code".isprintable()) # True
print("Hash Bang Code".endswith("Code")) # True
print("Hash Bang Code".startswith("Hash")) # True

print(len("Hash Bang Code")) # 14
print("Hash Bang Code".count("a")) # 2
print("Hash Bang Code".find("Bang")) # 5 
print("Hash Bang Code".index("Bang")) # 5

 

Add new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
4 + 2 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.