简体   繁体   English

谁能告诉我这段代码的逻辑错误在哪里?

[英]Can anybody tell me where the logic error is for this code please?

This is the piece of code and when I run the code nothing is outputted when the outputs should be the dice totals.Can somebody please help me identify the error这是一段代码,当我运行代码时,当输出应该是骰子总数时,什么都没有输出。有人可以帮我识别错误吗

import random
r1 = random.randint(1,6)
r2 = random.randint(1,6)
r3 = random.randint(1,6)


def ScoreDice(Dice1 , Dice2 , Dice3):
    Dice1 = r1
    Dice2 = r2
    Dice3 = r3

    if  Dice1 == Dice2 == Dice3:
        total = Dice1 + Dice2 +Dice3
        print(total)
    elif Dice1 == Dice2:
        total = Dice1 + Dice2 - Dice3
        print(total)
    elif Dice2 == Dice3:
        total = Dice3 + Dice2 - Dice1
        print(total)
    elif Dice1 == Dice3:
        total = Dice3 + Dice1 - Dice2
        print(total)
    else:
        total = 0
        print(total)
import random
r1 = random.randint(1,6)
r2 = random.randint(1,6)
r3 = random.randint(1,6)


def ScoreDice(Dice1 , Dice2 , Dice3):

    if  Dice1 == Dice2 == Dice3:
        total = Dice1 + Dice2 +Dice3
        print(total)
    elif Dice1 == Dice2:
        total = Dice1 + Dice2 - Dice3
        print(total)
    elif Dice2 == Dice3:
        total = Dice3 + Dice2 - Dice1
        print(total)
    elif Dice1 == Dice3:
        total = Dice3 + Dice1 - Dice2
        print(total)
    else:
        total = 0
        print(total)

ScoreDice(r1,r2,r3)

I guess you're new to coding... I suggest you work on logic and syntaxes first, before posting your questions.我猜你是编码新手……我建议你先研究逻辑和语法,然后再发布你的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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