In PS4 problem 3 I started out with this: count = 0 while count < len(shifts): for char in text: location = shifts[count][0] if text.index(char) >= location: but when I run it, it says substring not found for location in my if statement. However, if I simply print location it does so with no problems. Why is it not able to find it then in the conditional?
This means that in text.index(char), char was not in text, and so it raised an exception.
text.index(char) searches for char in text. If char is in text, it returns that index. Else, it raises an error.
Ok thank you, I switched it to text.find(char). I thought that text.index would work because I was inside a for loop for char in text, so I thought all of the char would be found
Welcome.
Join our real-time social learning platform and learn together with your friends!