0

I need to remove a certain element from a list of dictionaries. Unfortunately, the only reference to the object needing removal is a place in another list:

enemy_list[num]

I need to take out enemy_list[num] from everyone.

ii = 0
for i in enemy_list:
  print(ii, ':', enemy_list[ii])
  ii += 1
num = input("Which of your opponents would you like to eliminate? ")
num = int(num)
del everyone[enemy_list[num]]

I cannot remove it from only enemy_list because it is reset multiple times as everyone in list everyone takes a turn. I tried this question, but it only worked from removing entire lists from eachother. Is there a way I could change it to work for this case? Thanks for your time!

Frasher Gray
  • 222
  • 2
  • 14

1 Answers1

0
everyone.remove(enemy_list[num])
Sadru
  • 46
  • 1
  • 9