Pseudo Game of Cups in Python DESCRIPTION:
  [Inspired by Chandler's GameOfCups with Joey in "Friends"].
     Program gets 5-digit zipcode from user.  (Assume user won't make a
         mistake, and will enter exactly 5 digits).
     Program awards points based on a series of rules, and reports the total
         points earned at the end.
     The 8 rules are embedded as comments in the code.
     For each rule, besides adding points (or not) to the total, rule displays
         "Rule _ got _ points, so total is now _"
         (It prints this even if rule added 0 points to total).


"""
RULES
    +5 when first and last digit match
    +6 when second digit is twice the first AND third digit is greater than second or fourth digit
    +7 if any 7 is in the zipcode
    +8 when there's no "13" in MIDDLE the zipcode
    +9 when all three middle digits match
    +10 when third and fourth digits match
    +11 when zipcode is palindrome (12121 == 12121, while 12345 != 54321)
"""


Here is my solution to the challenge above:

zipcode = input("Enter your zipcode: ")
total_points = 0

#Rule 1

points = 5 if zipcode[0] == zipcode[-1] else 0
total_points += points
print(f"Rule 1 got {points} points, so total is now {total_points}")

#Rule 2

points = 6 if (int(zipcode[1]) * 2) &gt; int(zipcode[0]) and (int(zipcode[2]) &gt; int(zipcode[1]) or int(zipcode[2]) &gt; int(zipcode[3])) else 0
total_points += points
print(f"Rule 2 got {points} points, so total is now {total_points}")

#Rule 3

points = 7 if "7" in zipcode else 0
total_points += points
print(f"Rule 3 got {points} points, so total is now {total_points}")

#Rule 4

points = 8 if "13" not in zipcode[1:-1] else 0
total_points += points
print(f"Rule 4 got {points} points, so total is now {total_points}")

#Rule 5

points = 9 if zipcode[1] == zipcode[2] == zipcode[3] else 0
total_points += points
print(f"Rule 5 got {points} points, so total is now {total_points}")

#Rule 6

points = 10 if zipcode[2] == zipcode[3] else 0
total_points += points
print(f"Rule 6 got {points} points, so total is now {total_points}")

#Rule 7

points = 11 if zipcode == reversed(zipcode) else 0
total_points += points
print(f"Rule 7 got {points} points, so total is now {total_points}")

print(f"{zipcode} got {total_points} points!")


I feel like there is a much better way to do this. The print statements are repetitious, and reassigning points each time I check the zip code feels weird. Any suggestions are helpful and appreciated.
Your code can be simplified using a simple loop, eliminating most of the duplicated code:

def game_of_cups(zipcode, rules):

    total_points = 0

    for num, rule in enumerate(rules, 1):
        rule_passes = rule(zipcode)
        points = num + 4 if rule_passes else 0
        total_points += points
        print(f"Rule {num} got {points} points, so total is now {total_points}")

    print(f"{zipcode} got {total_points} points!")


You just need the appropriate rule functions, like:

def rule1(zipcode):
    return zipcode[0] == zipcode[-1]

def rule2(zipcode):
    a, b, c, d, e = map(int, zipcode)
    return b * 2 &gt; a and c &gt; min(b, d)

... etc ...


And then a list of rules to pass to the game:

rules = [ rule1, rule2, rule3, rule4, rule5, rule6, rule7 ]


Feel free to name the functions more appropriately; they don’t need to be named rule#.



Are you missing a rule?  You said there were 8 rules. 



Your implementation of rule#2 doesn’t match the comment description of rule #2.  I think it should be b == a * 2, not b * 2 &gt; a.