prefix_again¶
Requirements:
mathematical operations
substrings and slicing
loop with a counter variable
if, else
break
Get a string and a prefix length n from the user. Does a prefix of size n appear somewhere else in the string? Output True if it does, and False if not. Assume that string is not empty and that n is in the range 1..len(string).
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.