In [54]:
def shifted_diff(first, second):
# code here!
doubled = second * 2
print "Doubled:", doubled
if first not in doubled:
print "Not in"
return -1
for i in range(0, len(doubled) - len(first) - 1):
substring = doubled[i:i+len(first)]
print "Sub:", substring
if substring == first:
return i
return 0
In [48]:
print shifted_diff("coffee", "eecoff") # => 2
In [47]:
print shifted_diff("eecoff", "coffee") #=> 4
print shifted_diff("moose", "Moose") # => nil
print shifted_diff("isn't", "'tisn") # => 2
print shifted_diff("Esham", "Esham") # => 0
print shifted_diff("dog", "god") # => nil
In [55]:
print shifted_diff(" ", " ") # => nil
In [57]:
print shifted_diff("this shit is bananas","shit is bananasthis ")
In [58]:
print shifted_diff("this shit is bananas","nanasthis shit is ba")
In [79]:
def filter_list(l):
'return a new list with the strings filtered out'
return [ints for ints in l if str(ints).isdigit()]
In [80]:
filter_list([1, 2, 3, "1"])
Out[80]:
In [ ]:
In [73]:
a = "a"
a.isdigit
Out[73]:
In [ ]: