xyz_middle¶
Requirements:
mathematical operations
substrings and slicing
loop with a counter variable
Given a string, does "xyz"
appear in the middle of the string? To define middle, we’ll say that the number of chars to the left and right of the "xyz"
must differ by at most one. This problem is harder than it looks.
This exercise was taken from codingbat.com and has been adapted for the Python language. There are many great programming exercises there, but the majority are created for Java.