-3

Suuupppeeeeerrrrrr noob question,

I am trying to deconstruct some python code, and I can figure out what this line does. I know it cycles thru potentially 28 iterations but I can't figure out what the i%len does to question.

for i in range(t, t + 28):
    transmission.append(question[i%len(question)])

Thanks for your help.

eyesuk
  • 1
  • 3
  • You are correct about the 28 iterations. For the second line, look into the `.append()` [list method](https://docs.python.org/2/tutorial/datastructures.html#more-on-lists), and the modulo (`%`) [operator](http://www.learnpython.org/en/Basic_Operators). – maze88 Nov 01 '16 at 01:47

1 Answers1

0

The percent sign(%) is used to calculate the remainder. For example 3 % 2 = 1. In this case it's calculating the remainder of "i" divided by the length(len) of whatever "question" is.

Mike Beal
  • 9
  • 6