I have made a treasure hunt game, and I need it so that once a square containing a treasure chest has been visited 3 times it turns into a 'bandit'. In order to covunt the number of times a treasure chest has been visited, I added another lot of the same coordinates to the list of TreasureChestCoordinates. Then I plan to have an if statement so that if any of the coordinates are written 3 times, all 3 will be removed and put in the 'bandit' list. Here's my draft code for the section:
# Treasure Chests Collecting Coins #
if (x,y) in TreasureCoords[0:(TCNumber -1)]:
print("You have landed on a treasure chest! You can visit it 2 more times before it becomes a bandit.")
CoinCollection = CoinCollection + 10
TreasureCoords.append(x,y)
#if TreasureCoords.count(any item) > 3:
#remove all copies of item from list
#add item to bandit list
x,y means the coordinates the user is currently in. CoinCollection is a seperate variable that changes when the user lands on a treasure chest or bandit.By the way, the number of coordinates is unlimited because the user decides that earlier on in the game. So, how can I duplicate my list of coordinates, remove them once they are in the list 3 times and put them in a new list? I presume this is the easiest way to 'count' how many times the user has been on a square, and change the treasure chest to a bandit.