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
  While loop not ending (Best of 10 dice game) K3nidi 3 1,457 Jul-09-2022, 09:53 AM
Last Post: K3nidi
  Hi! + Poker calculator SpookyKooks 2 2,123 Mar-12-2020, 05:32 AM
Last Post: SpookyKooks
  Similar to Poker bluekade5050 1 27,943 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,467 Sep-30-2018, 01:19 PM
Last Post: Placebo
  Making a percentile dice roller and dice roller Fixer243 2 3,201 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