程序在不应该关闭时关闭

时间:2018-12-06 03:15:53

标签: python python-3.x

我正在做一个基于文字的游戏。

  1. 要求用户输入:
    • 名称
    • 困难
    • 技能水平

但是,一旦用户输入了难度,程序就会关闭。

任何帮助将不胜感激。

哦,请您在没有给出解释的情况下就拒绝投票,不是每个人都是Python大师。

P.S。对不起,英语破了

while True:
    print("Welcome to 'The imposible quest'")
    print("""



    """)
    name_charter = str(input("What's your name adventurer? "))
    difficulty = str(input("Please choose the difficulty level(easy, normal, hard): "))
    while set_difficulty==0:
        if difficulty=="easy":
            max_skill_start = 35
            player_max_hp = 120
            set_difficulty = 1
        elif difficulty=="normal":
            max_skill_start = 30
            player_max_hp = 100
            set_difficulty = 1
            elif difficulty=="hard":
            max_skill_start = 25
            player_max_hp = 80
            set_difficulty = 1
        else:
            print("ERROR, the option you chose is not a valid difficulty!")
    print("Hello" + nam_char + "/n /n Please choose your abilities, keep in mind that you can't spend more than" + max_skill_start + "points in your habilities: ")
    strength, dexterity, intelligence, perception, charm, combat, crafting, tradeing = input("Strength: "), input("Dexterity: "), input("Intelligence: "), input("Perception: "), input("Charm: "), input("Combat: "), input("Crafting: "), input("Tradeing: ")


    end_prg = str(input("Do you want to close the program(yes/no)? "))
    if end_prg=="yes":
        quit()
    elif end_prg=="no":
        print("""





    """)

1 个答案:

答案 0 :(得分:0)

您只需要在while循环之前将set_difficulty设置为0。另外,我看到您正在打印出大的空行,也可以使用print(“ \ n”)这将创建换行符。您可以按*按所需的数字添加多个:

print("\n"*10) //prints out 10 newlines.