简体   繁体   中英

I would like a few pointers for a program I'm trying to create in Python 3.3.3

So far, I've had a few bumps in the road, but I've been able to correct them, though my programming is quite sloppy as I've just started Python. The idea is to create a dice game called "Pig." The idea is that a user can roll or hold each turn and each subsequent roll adds to the players pot, though if you roll a 1 it's a bust and your pot is reset. Here is my program so far:

import random
die = random.randint(1,6)

R = (die)
r = (die)
H = (0)
h = (0)

User_Score = 0
Computer_Score = 0

pot1 = 0
pot2 = 0
User = input('Hello! Enter your name:')
Computer = 'AI'

if roll_again is 1:
    return take_turn(User)
elif roll_again is 0:
    take_turn(Computer)

print (User,"'s pot: ",pot1)
print (Computer,"'s pot: ",pot2)

if pot1 >= 50:
    User_Score += 1
if pot2 >= 50:
    Computer_Score += 1

def roll_die(random):
    numbers = [0]*6
    for n in range (1,6):
        die = random.randint (1,6)
        numbers = n
    return numbers

def take_turn(User):
    print ("It is your turn",User, input("Hit Enter to continue.")
    if input == True
(roll_die(random))
    if die == int(1)
        (pot1) is 0 and print("Die: 1 Pot: Bust! 0")
        else:
            print ("Die:",die, "Pot:",pot1)
        (pot1) =+ die
        (R,r,H,h) is raw_input ("(R)oll again or (H)old?")
        if input is(R,r)
            (roll_again) is 1
        else input is (H,h)
            (roll_again) is 0
        print (User,"'s pot: ",pot1)
        print (Computer,"'s pot: ",pot2)
    else
        return take_turn(User)
take_turn(User)
take_turn(Computer)

I seem to have a syntax error around the line 40 (I'm not sure exactly which line). Which is "if die == int(1)". I'm sure there are plenty of errors after that which I can solve on my own time, but getting past this roadblock would really be helpful! Thanks in advance.

There is no closing parenthesis at the end of line 38.

print ("It is your turn",User, input("Hit Enter to continue.")

This might be the error

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM