0

I am trying to create a war game where you can draft the countries you want to be your allies. I have 2 lists: countries, that has all available countries for the draft; and allies, which holds the countries that you pick.

The problem I am having is that instead of appending 1 country to allies, it appends all of them and leaves the one I picked in countries instead of allies.

The function answers is just a function that makes you choose the whatever is in the countries list and only the countries list.

I want it to be able to take the one country chosen at a time and put it into allies only.

Code:

countries = ['USA', 'AUSTRALIA', 'BRAZIL', 'CHINA', 'INDIA', 'NORTH KOREA', 'RUSSIA', 'SOUTH KOREA', 'TURKEY', 'PAKISTAN', 'IRAN', 'VIETNAM', 'EGYPT', 'SAUDI ARABIA']

allies = []

while 1 < len(countries):

        draft = answers( countries , "Please choose the country you would like as an ally: ALL CAPS! ")

        print(draft)

        #draft = input("Please choose the country you would like as an ally! ALL CAPS!: ")

        if draft == 'USA':

            print("We are adding it to a list")
            allies.append("USA")
        if draft == "AUSTRALIA" or "australia":
            allies.append("AUSTRALIA")
            countries.remove("AUSTRALIA")
khelwood
  • 55,782
  • 14
  • 81
  • 108
  • Instead of saying `if choice == 'USA'` or `if choice == 'RUSSIA'`, try `if choice in countries`. – Have a nice day May 10 '21 at 17:40
  • Please read the duplicate link above. You need either `if draft in ('AUSTRALIA','australia')`, or even better is `if draft.lower() == 'australia'` – Tim Roberts May 10 '21 at 17:40

0 Answers0