Skip to content

Instantly share code, notes, and snippets.

@KatiGithub
Created June 28, 2018 13:03
Show Gist options
  • Save KatiGithub/59b88df97c5df5980431a5e728c2ab6d to your computer and use it in GitHub Desktop.
Save KatiGithub/59b88df97c5df5980431a5e728c2ab6d to your computer and use it in GitHub Desktop.
This code has a for loop that runs through the people list and then seperate the list into even and odd indexes.
people = [
"A",
"B",
"C",
"D",
"E",
]
odd_people = []
even_people = []
i = 0
for i in range(0, len(people)):
if i % 2 == 0:
even_people.append(people[i])
else:
odd_people.append(people[i])
i = i + 1
print(odd_people)
print("-------------")
print(even_people)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment