Reputation: 3
I have a list named "ul_children", I need to use a for loop to print every other item in that list starting with the second item or the index[1]. I am new to for loops in python and I am struggling with this.
I have tried a few different things I thought would work, but I have been unsuccessful so far. Any help would be appreciated.
The closest I have gotten so far is by using:
i = 1
for li in ul_children:
print(ul_children[i])
but I don't know how to get 'i' to increase each time the loop is performed.
Upvotes: 0
Views: 918
Reputation: 11
You can do it like this:
ul_children = ["r","a","t","o","n"]
for i in ul_children[1:]:
print(i)
Upvotes: 1