Python石头剪刀布游戏不';我不能给出任何形式的输出

Python石头剪刀布游戏不';我不能给出任何形式的输出,python,Python,只要我按下“Run Module”,就会打开一个shell窗口,完全没有错误,但看起来好像什么都没有运行。我不知道为什么什么都没有发生,但我猜我在底部的代码块中的一些代码已经磨损得很厉害了。游戏是RPS-7,或者说是有7个选项的石头剪刀。我需要一些关于故障排除的帮助,因为似乎没有问题,但显然有问题(游戏实际上没有运行,它只是一个无用的外壳)。这是代码,这是我的第一个问题 import random def game(choice): options = ["Rock", "Paper",

只要我按下“Run Module”,就会打开一个shell窗口,完全没有错误,但看起来好像什么都没有运行。我不知道为什么什么都没有发生,但我猜我在底部的代码块中的一些代码已经磨损得很厉害了。游戏是RPS-7,或者说是有7个选项的石头剪刀。我需要一些关于故障排除的帮助,因为似乎没有问题,但显然有问题(游戏实际上没有运行,它只是一个无用的外壳)。这是代码,这是我的第一个问题

import random
def game(choice):
    options = ["Rock", "Paper", "Scissors", "Sponge", "Air", "Water", "Fire"]
    bot = random.choice(options)
    if choice == "Rock" and bot == "Scissors":
        print ("Rock crushes scissors, you win!")
    elif choice == "Rock" and bot == "Fire":
        print ("Rock pounds out fire, you win!")
    elif choice == "Rock" and bot == "Sponge":
        print ("Rock crushes sponge, you win!")
    elif choice == "Rock" and bot == "Paper":
        print ("Paper covers rock, you lose..")
    elif choice == "Rock" and bot == "Water":
        print ("Water erodes rock, you lose..")
    elif choice == "Rock" and bot == "Air":
        print ("Air erodes rock, you lose..")
    elif choice == "Rock" and bot == "Rock":
        print ("Rock tries to pound rock but fails, it's a tie!")
    elif choice == "Paper" and bot == "Rock":
        print ("Paper covers rock, you win!")
    elif choice == "Paper" and bot == "Water":
        print ("Paper floats on the water, you win!")
    elif choice == "Paper" and bot == "Air":
        print ("Paper fans the air, you win!")
    elif choice == "Paper" and bot == "Scissors":
        print ("Paper gets cut by the scissors, you lose..")
    elif choice == "Paper" and bot == "Fire":
        print ("Paper gets burned by the fire, you lose..")
    elif choice == "Paper" and bot == "Sponge":
        print ("Paper gets soaked by the sponge, you lose..")
    elif choice == "Paper" and bot == "Paper":
        print ("Paper tries to cover paper but fails, it's a tie!")
    elif choice == "Scissors" and bot == "Paper":
        print ("Scissors cuts paper, you win!")
    elif choice == "Scissors" and bot == "Air":
        print ("Scissors swishes through air, you win!")
    elif choice == "Scissors" and bot == "Sponge":
        print ("Scissors cuts sponge, you win!")
    elif choice == "Scissors" and bot == "Rock":
        print ("Scissors gets crushed by rock, you lose..")
    elif choice == "Scissors" and bot == "Fire":
        print ("Scissors gets melted by scissors, you lose..")
    elif choice == "Scissors" and bot == "Water":
        print ("Scissors gets eroded by water, you lose..")
    elif choice == "Scissors" and bot == "Scissors":
        print ("Scissors tries to cut scissors but fails, it's a tie!")
    elif choice == "Fire" and bot == "Scissors":
        print ("Fire melts scissors, you win!")
    elif choice == "Fire" and bot == "Paper":
        print ("Fire burns paper, you win!")
    elif choice == "Fire" and bot == "Sponge":
        print ("Fire burns sponge, you win!")
    elif choice == "Fire" and bot == "Rock":
        print ("Fire gets pounded out by rock, you lose..")
    elif choice == "Fire" and bot == "Air":
        print ("Fire gets blown out by air, you lose..")
    elif choice == "Fire" and bot == "Water":
        print ("Fire gets put out by water, you lose..")
    elif choice == "Fire" and bot == "Fire":
        print ("Fire tries to burn fire but fails and creates a bigger fire, creating the biggest brushfire known to man. Therefore, it's a tie!")
    elif choice == "Sponge" and bot == "Air":
        print ("Sponge uses air pockets, you win!")
    elif choice == "Sponge" and bot == "Paper":
        print ("Sponge soaks paper, you win!")
    elif choice == "Sponge" and bot == "Water":
        print ("Sponge absorbs water, you win!")
    elif choice == "Sponge" and bot == "Rock":
        print ("Sponge gets crushed out by rock, you lose..")
    elif choice == "Sponge" and bot == "Fire":
        print ("Sponge gets burnt by fire, you lose..")
    elif choice == "Sponge" and bot == "Scissors":
        print ("Sponge gets cut by scissors, you lose..")
    elif choice == "Sponge" and bot == "Sponge":
        print ("Sponge tries to absorb sponge but fails and solves the world's water problem, however, it's a tie!")
    elif choice == "Water" and bot == "Rock":
        print ("Water erodes rock, you win!")
    elif choice == "Water" and bot == "Fire":
        print ("Water puts out fire, you win!")
    elif choice == "Water" and bot == "Scissors":
        print ("Water rusts scissors, you win!")
    elif choice == "Water" and bot == "Sponge":
        print ("Water gets absorbed by sponge, you lose..")
    elif choice == "Water" and bot == "Air":
        print ("Water gets evaporated by air, you lose..")
    elif choice == "Water" and bot == "Paper":
        print ("Water gets floated on by paper, you lose..")
    elif choice == "Water" and bot == "Water":
        print ("Water tries to put out water, but fails, creating a large tsunami that wipes out San Francisco. This seems oddly familliar to a song. It's a tie!")
    elif choice == "Air" and bot == "Fire":
        print ("Air blows out fire, you win!")
    elif choice == "Air" and bot == "Rock":
        print ("Air erodes rock, you win!")
    elif choice == "Air" and bot == "Water":
        print ("Air evaporates water, you win!")
    elif choice == "Air" and bot == "Paper":
        print ("Air gets fanned by paper, you lose..")
    elif choice == "Air" and bot == "Scissors":
        print ("Scissors swish through air, you lose..")
    elif choice == "Air" and bot == "Sponge":
        print ("Sponges use air pockets, you lose..")   
    elif choice == "Air" and bot == "Air":
        print ("Air tries to blow out air, fails, and creates a tornado. It's a tie!")
def again(x):
    while True:
        if x == "y":
            game(raw_input("Rock, Paper, Scissors, Sponge, Air, Water, or Fire?"))
            again(raw_input("Play RPS - 7 again? y / n."))
        else:
            print ("Goodbye.")
        break
        break
        game(raw_input("Rock, Paper, Scissors, Sponge, Air, Water, or Fire?"))
        again(raw_input("Play RPS - 7 again? y / n."))
运行代码时会发生什么情况:


您首先需要调用一个函数-现在,您只是在定义函数。加

again('y')

作为启动循环的文件的最后一行。

您定义了两个函数,并在从未调用它们的情况下退出。整个主程序由
import
语句组成。在底部,您似乎需要这样的内容:

再次('y')


作为你的主要节目。这将再次运行
功能
一次。

请阅读并遵循帮助文档中的发布指南,正如您创建此帐户时所建议的那样。适用于这里。这段代码一点也不简单。说到这一点,我强烈建议您采用增量编程:编写几行代码,测试这些代码,在这些代码满足您的要求之前不要添加新功能。在这里,当你甚至还没能进入游戏时,你已经敲出并发布了100行未经测试的代码。尝试一个简单的“石头布”游戏,直到你的主循环开始工作。只是好奇——你是如何找到这个扩展而不是“石头布剪刀蜥蜴斯波克”?:-)啊,我知道RPS蜥蜴斯波克,但我在寻找更多的东西。这是我增量编程之旅的开始,因为一旦我发现问题所在,我将继续深入列表。当你得到一个解决方案时,请记住向上投票,并接受你最喜欢的答案(即使你必须自己写),这样Stack Overflow就可以正确地存档问题。仍然没有什么,但这一次('y')又是一个错误。