mercredi 15 février 2017

How to make random numbers work in python

I am currently trying to make a text base game. I need help make a random number 'spawn' something. Below is what I have so far it runs but it only goes to the else statement.

import random

beast = random.randint(0, 6)

    if beast == '0':
        print("Phew, it was just a active bunny")
    elif beast == '1':
        print("UH-OH, it was a sabertooth tiger! You better continue to remain calm")
    elif beast == '2':
        print("turns out it was just a friendly dog. As you stare at him he start licking your face and wanting to be petted")
    elif beast == '3':
        print("WHAT THE HECK! It is a great white shark! First off what is it doing out of the water. Second.... ")
        print("You were eaten by the shark. Game over")

        while True:
            restart = input("Would you like to try again? Type 'Y' or 'N' ")

            if restart == 'Y':
                intro()
            else:
                print("Thanks for playing, hope you come back again! ")
                quit()
    elif beast == '4':
        print("OOH Come on! Turns out it was a bull. As soon as your eyes meet though it ran off. 'Weird' you think to yourself!")
    else:
        print("Weird, there was nothing behind you... You start hearing a rumbling coming from the ground behind you")
        print("You turn around, right as you do you start seeing, what looks like a rock giant, rising from the ground. The rock giant spins around and stares at you!")




Aucun commentaire:

Enregistrer un commentaire