deck = ['1c', '4s', '8s', '8h', '1h', '2s', '2c', '8h', 'ks', 'qd', '4d', 'jd', '7c', '10h', '5c', '10d', '3d', '9c', '7d', '4h', '2s']
powerCard = "1c"
def deckStrength(powerCard, deck):
# global deck
powerCardExists = False
for card in deck:
if card == powerCard:
powerCardExists = True
if(powerCardExists):
deck.remove(powerCard)
for card in deck:
card = card[:-1]
print(deck)
deckStrength(powerCard, deck)
If you run this, the output will be:
['4s', '8s', '8h', '1h', '2s', '2c', '8h', 'ks', 'qd', '4d', 'jd', '7c', '10h', '5c', '10d', '3d', '9c', '7d', '4h', '2s']
As you can see, with the last for loop in my deckStrength function, I was trying to get rid of the last character in each string within my deck list. This didn't transpire, any clue as to why?
I also want to add that I tried doing this without deck as a parameter for the function and calling "global deck" but that didn't work so I tried this.