String Operators & Functions
String Operators
# String Operation Examples
word1 = 'Hello, '
word2 = 'World!'
print('word1 + word2:', word1 + word2) # Concatenation
word3 = word1[:-2] # Slicing, resulting slice assigned to variable: word3
print('word3*3:', word3*3) # Repetition
print("'H' in word1:",'H' in word1) # Membership
print("'or' not in word2:", 'or' not in word2)
Built-in Functions with Strings
Last updated