Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexError: pop from empty list #8

Closed
Puffball101961 opened this issue Jun 18, 2021 · 1 comment
Closed

IndexError: pop from empty list #8

Puffball101961 opened this issue Jun 18, 2021 · 1 comment

Comments

@Puffball101961
Copy link

I am trying to repeatedely evaluate random hands with the deck.draw() method, however after a few times of running it sequentially, it returns an error:

File "c:\Users\XXXXX\main.py", line 57, in <module>
    evalHand()
  File "c:\Users\XXXXX\main.py", line 14, in evalHand
    board = deck.draw(5)
  File "C:\Python39\lib\site-packages\treys\deck.py", line 27, in draw
    cards.append(self.draw())
  File "C:\Python39\lib\site-packages\treys\deck.py", line 23, in draw
    return self.cards.pop(0)
IndexError: pop from empty list
@michael-berk
Copy link

michael-berk commented Aug 23, 2021

You need to reshuffle the deck or create a new one.

from treys import Deck
d = Deck()
for x in range(100):
    d.shuffle()
    print(d.draw(2))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants