Hello strings
#
# hello_strings.py
#
= "HelloWorld"
hello print("hello: ", hello)
print("len(hello): ", len(hello))
# String indexing is 0-based, and you create substrings with the
# slice notation (like lists).
print("hello[0]: ", hello[0])
print("hello[0:5]:", hello[0:5])
print("hello[5:]: ", hello[5:])
print("hello[5:-2]: ", hello[5:-2])
# f-strings can be useful for creating strings that contain Python
# expressions
print(f"hello: {hello} {len(hello)} {len(hello) == 10}")
Output:
hello: HelloWorld
len(hello): 10
hello[0]: H
hello[0:5]: Hello
hello[5:]: World
hello[5:-2]: Wor
hello: HelloWorld 10 True