Python随机数拼图不起作用

2024-04-20 11:52:38 发布

您现在位置:Python中文网/ 问答频道 /正文

每当我对"would you like to attempt the puzzle?"这件事说“不”的时候,什么都不会出现。我甚至只在所有代码后面加了一个print ("test"),但它没有执行测试

puzzle1 = raw_input ("The cave has a small golden inscription on the door with a dial for imputting numbers. A puzzle! Would you like to attempt the puzzle?")
    #Puzzle 1
if path1 == "2":
    while breakhold2 == 0:
        if path1 == "2":
            if puzzle1.lower in ["Yes", "Ye", "Y", "y", "ye", "yes"]:
                print ("You press the button on the door. A small dial turns quickly and picks a random number between 1 and 50. Now you must guess the number being told to go 'higher' or 'lower'. You have only 5 tries to guess the random number.")

if path1 == "2":
    while breakhold2 == 0:
        if path1 == "2":
            if puzzle1.lower in ["Yes", "Ye", "Y", "y", "ye", "yes"]:
                from random import randrange
                puzzle1number = randrange(1,51)
                puzzle1number2 = raw_input ("What is the first guess? You have 5 tries left.")
                if int(puzzle1number2) == puzzle1number:
                    print ("You did it first try! Lucky you!")
                if int(puzzle1number2) > puzzle1number:
                    print ("Lower!")
                if int(puzzle1number2) < puzzle1number:
                    print ("Higher!")
                if int(puzzle1number2) == puzzle1number:
                    breakhold2 += 1
                    break
                else:
                    puzzle1number3 = raw_input ("What is the second guess? You have 4 tries left.")
                if int(puzzle1number3) == puzzle1number:
                    print ("You did it second try! Great guessing!")
                if int(puzzle1number3) < puzzle1number:
                    print ("Higher!")
                if int(puzzle1number3) > puzzle1number:
                    print ("Lower!")
                if int(puzzle1number2) == puzzle1number or int(puzzle1number3) == puzzle1number:
                    breakhold2 += 1
                    break
                else:
                    puzzle1number4 = raw_input ("What is the third guess? You have 3 tries left.")
                if int(puzzle1number4) == puzzle1number:
                    print ("You did it third try! Great guessing!")
                if int(puzzle1number4) < puzzle1number:
                    print ("Higher!")
                if int(puzzle1number4) > puzzle1number:
                    print ("Lower!")
                if int(puzzle1number4) == puzzle1number or int(puzzle1number4) == puzzle1number:
                    breakhold2 += 1
                    break
                else:
                    puzzle1number5 = raw_input ("What is the fourth guess? You have 2 tries left.")
                if int(puzzle1number5) == puzzle1number:
                    print ("You did it fourth try! That came kind of close.")
                if int(puzzle1number5) < puzzle1number:
                    print ("Higher!")
                if int(puzzle1number5) > puzzle1number:
                    print ("Lower!")
                if int(puzzle1number5) == puzzle1number or int(puzzle1number5) == puzzle1number:
                    breakhold2 += 1
                    break
                else:
                    puzzle1number6 = raw_input ("What is the fifth and final guess? This is your last try!")
                    if int(puzzle1number6) == puzzle1number:
                        print ("Finally! Got it on the last go!")
                    else:
                        print ("Blast! The small dial clicks and becomes unmovable. Whatever treasure was in there is now locked inside. I wonder why that was a lock?")
                        breakhold2 += 1
                        break

if path1 == "2":
    while breakhold2 == "0":
        if puzzle1.lower in ["No", "no", "n", "N"]:
            print ("You decide not to attempt the puzzle.")          
            breakhold2 += 1
            break

Tags: theyouinputrawifisintprint