maybe it's because I haven't coded for a few days, but I can't understand why this isn't working. The condition of if i == enemy_spaceship_index is being met once in the for loop, and yet the code beneath that conditional if statement is not executing. When I print out the list, it's just giving me seven 2s. What is should be doing is printing six 2s and a 3. The position of the 3 in the list is determine by enemy_spaceship_index. Any help would be appreciated.
enemy_spaceship_index = randint(0, 6)
appearancesLeft = []
for i in range(7):
if i == enemy_spaceship_index:
appearancesLeft.append(3)
elif i != enemy_spaceship_index:
appearancesLeft.append(2)
print appearancesLeft
Aucun commentaire:
Enregistrer un commentaire