Addition of strings:
print('hello' + ' '+ 'FACE Prep')
hello FACE Prep
Multiplication of strings:
variable1= 'hello' *3
variable2= 'FACE Prep'
hello hello hello FACE Prep
Length of a string:
str1= 'FACE Prep'
"In" function: checks if variable is present in the sequence and exits a binary output, i.e True or False. For example,
'n' in fruit # returns answer True
'm' in fruit # returns answer False
#this can be used in "if" function as shown below:
if 'a' in fruit:
If you want to add material to the end of a string successively, we can append it manually by the operator +=. This is further illustrated in the following example.
str3 = 'hello' str3 += ' ' str3 += 'FACE Prep' print(str3) -> hello FACE Prep