-1
l = ['a', 'b', 'c', 'd', 'e', 'f', 'g']
for x in l:
  print(S[::2], [1::2])

what does the print statement mean in this program

John La Rooy
  • 295,403
  • 53
  • 369
  • 502
Thani
  • 13
  • 1
  • 2

1 Answers1

3

A double colon ::x means to skip by x. In this case it is skipping by 2. So if you have l=[ 'a','b','c','d','e','f','g'] and you want to find l[::2], then starting at 'a', you move to 'c', and so on.

Now, if you have a number before the colons, such as x::y. This means to start at index x and skip by y.