Python Forum
Thread Rating:
  • 2 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Poker Dice while loop
#3
(May-28-2017, 08:03 PM)ichabod801 Wrote: 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).
Thank You!
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
  Hi! + Poker calculator SpookyKooks 2 1,130 Mar-12-2020, 05:32 AM
Last Post: SpookyKooks
  Similar to Poker bluekade5050 1 1,139 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 2,004 Sep-30-2018, 01:19 PM
Last Post: Placebo
  Making a percentile dice roller and dice roller Fixer243 2 1,597 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