So I have a double problem. I have selectedCards
list, which contains 2 elements - card rank and suit, in this format: ['6', 'c']
club = u"\u2663" # Unicode codepoint for club
newList = [club for i in selectedCards if i == 'c' else i]
I want to change 'c' into graphical representation of club, but this expression not working. I tried searching a lot but couldn't find what's wrong. It says: SyntaxError: invalid syntax
Second problem, If I remove else statement, then it works, but it does not output what I want, it looks like this: [u'\u2663']
, even thought print(club) outputs ♣.
EDIT: newList = [club if i == 'c' else i for i in selectedCards]
is the correct syntax, thanks to xtofl.