Skip to main content

Timeline for Console-based hangman in Python

Current License: CC BY-SA 4.0

7 events
when toggle format what by license comment
Jan 7, 2020 at 14:25 vote accept Roddy of the Frozen Peas
Jan 6, 2020 at 10:48 comment added Jörg W Mittag @RoddyoftheFrozenPeas: It is also very easy to introduce bias when rolling your own sampling functions; I would generally trust the standard library implementations more than my own. (Although of course, standard library implementations of PRNGs and sampling have been known to be wrong, and sometimes quite spectactularly so.)
Jan 6, 2020 at 6:28 comment added Green Cloak Guy @RoddyoftheFrozenPeas In terms of why random.choice() over alternatives: it's mainly because of simplicity. Using rand.randint() and then choosing an index is two steps, and could lead to an IndexError depending on the circumstances/synchronicity. random.choice() is one step, is very straightforward (chooses one element from the list), and has no chance of IndexError unless the list is empty (again, only one step). "Take a random element from this list" is a cleaner and simpler expression than "Find a random index less than the size of the list, and take the element at that index".
Jan 6, 2020 at 4:11 comment added Roddy of the Frozen Peas With regards to using classes and sets ... I'm actually using a book to teach myself the Python concepts and haven't gotten to that part yet. I'll be sure to keep reading and do a refactor with your suggestions in mind. :)
Jan 6, 2020 at 3:59 comment added Roddy of the Frozen Peas Can you link me to something that elaborates on why one should prefer random.choice over randint and randrange? I've tried googling but I'm not getting anything definitive. When I Googled how to get a random integer when writing the original, both posts I looked at (one on StackOverflow, the other elsewhere) recommended randint, which is why I used it.
Jan 5, 2020 at 13:10 history edited Peilonrayz CC BY-SA 4.0
Fix spelling
Jan 5, 2020 at 10:04 history answered Peilonrayz CC BY-SA 4.0