mercredi 30 octobre 2019

If/elif wrong display of "random" output

## After input amount of chips and amount of bet and choose number, the number is always red, this worked few days ago but i changed something and there is impossible to get "black" ## If elif statement is considering only when IF is not True, then i dont get why spin= number from second pool of numbers but there is "red" from first statement

import random
#program
while True:
    print("Enter 'rules' to show rules")
    print("Enter 'play' to play the game")
    print("Enter 'author' to show info about creator")
    print("Enter 'quit' to end the program")
    user_input=input()
    if user_input.lower()=="quit":
        break
    elif user_input.lower()=="rules":
        print(cont)
    elif user_input=="play":
        while True:       #LOOOP IN DA LOOOP
            start=int(input("How much chips you want for start?\n"))
            amount=int(input("How much you want bet\n"))
            bet=int(input("Place your bet\n"))
            spin=random.randint(0,36)
            #Continue/break?
            if bet>36:
                print("There is only 36 numbers!")
            elif bet<0:
                print("You need bet number beetwen 0 and 36")
            elif spin==bet:
                print("You won",amount*35)
                print("Now you have",start-amount+amount*35)
            else:
                print("You lose")
                print("Now you have",start-amount) #Aktualizacja stacka
                if spin==1 or 3 or 5 or 7 or 9 or 12 or 14 or 16 or 18 or 19 or 21 or 23 or 25 or 27 or 30 or 32 or 34 or 36:
                    print(spin,"red")
                elif spin==2 or 4 or 6 or 8 or 10 or 11 or 13 or 15 or 17 or 20 or 22 or 24 or 26 or 28 or 29 or 31 or 33 or 35:
                    print(spin,"black")
                else:
                    print(spin,"green")
    elif user_input=="author":
         print("Jacob X")
    else:
         print("Unknown command")



Aucun commentaire:

Enregistrer un commentaire