Lucifer
Lucifer

Reputation: 3

Code is showing (TypeError: 'NoneType' object is not iterable)

(starting code) My code is showing (TypeError: 'NoneType' object is not iterable) error even the variable I am using is contains some value. This is the code I am talking about

Upvotes: 0

Views: 174

Answers (2)

bio_dan
bio_dan

Reputation: 78

The problem is in how you are appending values to your list users_cards.

You have written users_cards = users_cards.append(random.choice(cards)).

The append function automatically updates the object so the code should read: users_cards.append(random.choice(cards)) (no need for the users_cards = bit)

Upvotes: 1

Daniel Kusy
Daniel Kusy

Reputation: 343

Your user_cards is None. You need an iterable there (list, tuple etc) because you've used sum function on that. Make sure user_cards is initialized.

Upvotes: 0

Related Questions