Created
June 28, 2018 13:03
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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