+ 3

What does this code before the for loop do?

Hi, I have this code where it will split a string into a list containing 2 characters each, but I don't understand what does the "(string[i:i+n])" before the "for" does May anyone explain? Answers appreciated https://code.sololearn.com/cy7BHXoFS7K4

3rd Sep 2019, 3:11 PM
Steven Sim
Steven Sim - avatar
4 Answers
+ 4
Ah, Steven Sim, then it's about comprehensions! Take a look here: https://code.sololearn.com/ck6HicJ6Z8jG/?ref=app
3rd Sep 2019, 4:22 PM
HonFu
HonFu - avatar
+ 4
That's slice notation. Take a look at the link. (If it's still not clear, please keep asking.) https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2453/?ref=app
3rd Sep 2019, 3:13 PM
HonFu
HonFu - avatar
+ 3
I had a weird problem while trying to send my answer. I have my answer in this code: https://code.sololearn.com/c8aZ2pnhsYmO/?ref=app
3rd Sep 2019, 3:28 PM
Seb TheS
Seb TheS - avatar
+ 2
HonFu Hi, I know that it's a slice notation, but what I don't understand is why is it written before the for loop Seb TheS Thank you for the alternative, though if possible I will appreciate a lot for an explanation of what I asked
3rd Sep 2019, 4:16 PM
Steven Sim
Steven Sim - avatar