PYTHON | how do I convert a list into numbers? this code creates a list of pairs. v = ['A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K'] s = ['C','D','H','S'] deck = [(x+'-'+y) for y in s for x in v] the output of the above code is the 'the list'. I want to convert it into numbers so that I can compare them and use '>' & '<' for example: the pair 'A-C' is less than the pair 'A-D' (both have the same 'v' but different in 's' and the 's' in pair 1 is C and is lower in ranking than 'D') now I can't simply code deck[0] < deck[13] since that wouldn't make sense since the list is a made-up of both numeric and non-numerical varialbles. you can use deck[0][0] style in your code. So, how do I do this? Use this as reference for the ranking Ranking of 's' from lowest to highest is Clubs, Diamonds, Hearts, Spades Ranking of 'v' from lowest to highest is 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K, A There are no jokers.
PYTHON | how do I convert a list into numbers?
this code creates a list of pairs.
v = ['A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K']
s = ['C','D','H','S']
deck = [(x+'-'+y) for y in s for x in v]
the output of the above code is the 'the list'. I want to convert it into numbers so that I can compare them and use '>' & '<'
for example:
the pair 'A-C' is less than the pair 'A-D' (both have the same 'v' but different in 's' and the 's' in pair 1 is C and is lower in ranking than 'D') now I can't simply code deck[0] < deck[13] since that wouldn't make sense since the list is a made-up of both numeric and non-numerical varialbles.
you can use deck[0][0] style in your code.
So, how do I do this?
Use this as reference for the ranking
Ranking of 's' from lowest to highest is Clubs, Diamonds, Hearts, Spades
Ranking of 'v' from lowest to highest is 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K, A
There are no jokers.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images