I got the following code.
hand = '6C 7C 8C 9C TC'.split()
so hand is now a list of strings ['6C', '7C', '8C', '9C', 'TC']
then
ranks = ["--23456789TJKA".index(r) for r, s in hand]
ranks is now [6, 7, 8, 9, 10]
The aim is to give card's rank the proper numeric value to allow sorting it: i.e. 'T'->10, 'J'->11, 'Q'-12, 'K'->13 and 'A'->14.
I don't understand why it works!
- to get an item from a list is
list[item]
- to slice a string is
"string"[0]
I do not see it in the ranks list comprehension.
Thank you!