Reputation: 17
Any idea why i get this message for the below code? "unsupported operand type(s) for +: 'range' and 'int'"
# Hearts, Spades, Clubs, Diamonds
suits = ['H', 'S', 'C', 'D']
card_val = (range(1, 11) + [10] * 3) * 4
base_names = ['A'] + range(2, 11) + ['J', 'K', 'Q']
cards = []
for suit in ['H', 'S', 'C', 'D']:
cards.extend(str(num) + suit for num in base_names)
deck = Series(card_val, index=cards)
Upvotes: 1
Views: 127
Reputation: 22885
I think you are using Python 3 and range()
is a generator in python 3. Encapsulate range inside a list. list(range(10))
card_val = (list(range(1, 11)) + [10] * 3) * 4
Upvotes: 2