Hi. Explain this python string rotation program | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Hi. Explain this python string rotation program

Since this is one-liner. I didn't get anything. pls break this code and explain. https://code.sololearn.com/cjAUZf32GPg5/?ref=app

29th Jul 2018, 6:21 AM
Uttam
Uttam - avatar
2 Answers
+ 4
Here it is in 3 lines string = input() for i in range(len(string)): print(string[i:] + string[:i])
29th Jul 2018, 9:40 AM
David Ashton
David Ashton - avatar
+ 2
input() | Takes an input, for i in range(len(x)) | loops through the index values for the string based on string length lambda x: [x[i:]+x[:i] | Take every letter after i character(including i) and then put every character before i
29th Jul 2018, 6:39 AM
JME