Python不允许我将变量添加到另一个

时间:2019-11-13 10:54:19

标签: python function variables addition

您能帮我吗,我不确定为什么它会在最后一行的“ =”上给我一条错误消息,提示语法错误。

#import stuff
import random

#players enter names
p1 = input("Player1,¿Como te llamas?")
p1score = 0
p2 = input("Player2,¿Como te llamas?")
p2score = 0

#functions
def rollp1():
    score1 = random.randrange(1,7)
    score2 = random.randrange(1,7)
    turnscore = score1 + score2
    if turnscore % 2 == 0:
        turnscore = turnscore + 10
    else:
        turnscore = turnscore - 5
    print (p1,"Got a score of", turnscore)
    global p1score = p1score + turnscore

enter image description here

0 个答案:

没有答案