Why do x
and y
have no output in the code below? It only happens when the substring is less than 0: "3"
textString = "You can milk a yak in London Zoo"
print(textString)
a = len(textString) #puts a = 32
b = textString.index('milk') #puts 8 in b
c = textString[11:17] #puts "k a yak" in c
# You could find the positions of the spaces in c
# but this solution assumes they are known
x = c[0:0] #puts “k” in x
y = c[2:2] #puts “a” in y
z = c[4:6] #puts “yak” in z
result = x+y+z
print(x)
print(y)
print(z)
print(result)