Examples of using stringh and list functions.
print("Call lower function on a string literal")
print("UPPER CASE".lower())
print("\nCall lower function on a string variable")
string_var = "Run JUMP Swim!"
print(string_var.lower())
print("\nCall upper function on a string")
print(string_var.upper())
print("\nSplit a string into a list of words")
print(string_var.split())
print("\nSplit a string on a specific character (U)")
print(string_var.split('U'))
print("\nFor loops and lists")
string_list_data = string_var.split()
for item in string_list_data:
print(item + ": " + str(len(item)))
print("\nAccess an item in a list with an index")
print(string_list_data[1])
print("\nAccess items in a list using for and range")
for index in range(len(string_list_data)):
print(str(index) + ": " + string_list_data[index])
print("\nif statement with a list")
if 'swim!' in string_var.lower().split():
print("Found!")
else:
print("Not Found")
print("\nFind index of item in list")
index = string_list_data.index("JUMP")
print(index)
print("\nUse newline and tab in a string")
print("Hello\tthere\nNice to meet you!")