def where(s,c): '''Given string s and single-character string c, return the position of the first occurrence of c in s. If c is not in s, return -1.''' # Do not use any string methods, but you can use functions in __builtins__ def every_ith(l,i): '''Given list l and int i > 0, return a new list that contains every ith element of l, starting with index 0.''' # You can assume that i is > 0. You don't need to perform error checking on that. def duplicates(l): '''Return True if list l contains adjacent elements with the same value, and False otherwise''' # Use a while loop rather than a for-loop if __name__ == '__main__': print where("abcdeddw x",'d'), "sb", 3 print where("a",'a'), "sb", 0 print where("abcdeddw x",'x'), "sb", 9 print where("abcdeddw x",'z'), "sb", -1 print where("",'z'), "sb", -1 print every_ith([10,11,12,13,14,15,16,17],3), "sb", [10,13,16] print every_ith([10,11,12,13,14,15,16,17],10), "sb", [10] print every_ith([],2), "sb", [] print every_ith([1,2,3],1), "sb", [1,2,3] # You decide on a good set of test cases here for duplicates