I come from a C-like language background, so the code below looks pretty confusing to me:
#source: https://www.youtube.com/watch?v=4n7NPk5lwbI (timestamp 3:39)
def rotation(t):
""" Return list of rotations of input string t"""
tt = t * 2 #why??, and is this concatenation?
return [ tt[i:i+len(t)] for i in xrange(0, len(t)) ] #what is this for loop return/splice?
This should produce for a given input, say t = "abc$"
:
[[abc$], [bc$a], [c$ab], [$abc]]
Or some permutation of the above output. Could someone explain what this code is doing? Including an example of input/output. I got a vague idea when typing this out, but it would help me to hear from someone that knows python.