简体   繁体   English

我总是得到最终的印刷品,甚至写下我想要的 class。 我该如何解决?

[英]I always get the final print, even writing the class that I want. How do I fix this?

So, I'm trying to create a RPG just for fun.所以,我只是为了好玩而尝试创建一个角色扮演游戏。 But, while creating the classes, I noticed that I couldn't choose my class. Everytime I choose a class, I always get the final print.但是,在创建课程时,我注意到我无法选择我的 class。每次我选择 class 时,我总是得到最终打印。 How do I fix this?我该如何解决?

while (True):
    print("Select your class\n")
    print("\nKnight\nArcher\nTank\nRogue\n\n")

    classe = input("")

    if((classe.strip()).lower() == "Knight"):
        forca = 10
        defe = 4
        hp = 8
        agi = 2
        inte = 2
        break

    elif((classe.lower()) == "Archer"):
        forca = 6
        defe = 6
        hp = 6
        inte = 8
        agi = 7
        break

    elif((classe.strip()).lower() == "Tank"):
        forca = 5
        defe = 8
        hp = 10
        inte = 3
        break

    elif((class.strip()).lower() == "Rogue"):
        strenght += 6
        def = 5
        hp = 5
        inte = 6
        agi = 10
        break
    else:
        print("You need to choose one.")

You are using .lower() then comparing it to words with capital letters ( Tank ).您正在使用.lower()然后将其与大写字母 ( Tank ) 的单词进行比较。 So it will never match.所以它永远不会匹配。 Try this:尝试这个:

while (True):
    print("Select your class\n")
    print("\nKnight\nArcher\nTank\nRogue\n\n")

    classe = input("")

    if((classe.strip()).lower() == "knight"):
        forca = 10
        defe = 4
        hp = 8
        agi = 2
        inte = 2
        break

    elif((classe.lower()) == "archer"):
        forca = 6
        defe = 6
        hp = 6
        inte = 8
        agi = 7
        break

    elif((classe.strip()).lower() == "tank"):
        forca = 5
        defe = 8
        hp = 10
        inte = 3
        break

    # class is a keyword, use classe
    elif((classe.strip()).lower() == "rogue"):
        # Does this need to be an equals?
        strenght = 6
        # Def is a keyword, use defe
        defe = 5
        hp = 5
        inte = 6
        agi = 10
        break
    else:
        print("You need to choose one.")

暂无
暂无

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

相关问题 “扩展”不会做我想做的。 如何在 Snakemake 中为规则生成自定义输入列表? - 'expand' won't do what I want. How do I generate a custom list of inputs to a rule in Snakemake? 我得到退出代码 0 但程序没有做我想要的。 看起来它卡在第一行代码中 - I get Exit code 0 but the program doesn't do what i want. Looks like it gets stuck in the first line of code 如何获取此代码以打印我想要的内容? - How do I get this code to print what I want? 我想打印一个字符串中的所有字母,但我没有得到 output,甚至没有错误 - I want to print all alphabet letters in a string, but I do not get an output, not even an error 使用拉格朗日插值不能按我想要的方式工作。 如何使用对数函数进行插值? - Interpolation using Lagrange not working how I want. How can I interpolate with a logarithmic function? 我该如何修正我的代码,以便它可以打印出我想要的结果? - How Do I Fix My Code So It Can print() Out The Results I Want? 我该如何解决这个问题 我想使用 while 循环来解决它 - How do I fix this I want to solve it using a while loop 我想在 for 循环结束时打印“否”。 我应该怎么做? - I want to print 'No' at end of the for loop. How should I do? 如何使用函数打印我想要的句子? - How do I use functions to print a sentence I want? Merge on Nan - 这个错误是我想要的行为。 我应该担心未来的修正吗? - Merge on Nan - The bug is the behavior I want. Should I worry about future correction?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM