Python Forum
Thread Rating:
  • 2 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Poker Dice while loop
#2
This is your error:

if fa == 'yes' or 'y':
Python reads it like this:

if (fa == 'yes') or ('y'):
Since any non-empty string evaluates as True, the second part is True, and the whole expression is always True. You want:

if fa == 'yes' or fa == 'y':
or

if fa in ('yes', 'y'):
I would also use break instead of quit, and more descriptive variable names (a and fa are confusing). Also, if you put the three dice into a list, and then sort that list, then the comparisons are much easier (especially for straights).
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
Poker Dice while loop - by gullidog - May-28-2017, 07:48 PM
RE: Poker Dice while loop - by ichabod801 - May-28-2017, 08:03 PM
RE: Poker Dice while loop - by gullidog - May-28-2017, 08:07 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  While loop not ending (Best of 10 dice game) K3nidi 3 1,487 Jul-09-2022, 09:53 AM
Last Post: K3nidi
  Hi! + Poker calculator SpookyKooks 2 2,161 Mar-12-2020, 05:32 AM
Last Post: SpookyKooks
  Similar to Poker bluekade5050 1 31,744 Nov-14-2018, 04:46 PM
Last Post: j.crater
  Issue with my 'roll the dice simulation'-exercise (cannot break out of the loop) Placebo 2 3,502 Sep-30-2018, 01:19 PM
Last Post: Placebo
  Making a percentile dice roller and dice roller Fixer243 2 3,236 Sep-30-2018, 12:18 PM
Last Post: gruntfutuk

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020