jeudi 12 avril 2018

Python wont continue to next if statement

I think it's important to say that I started coding just a few days ago.

So I built this Rock, Paper, Scissors game that allows you to play against the computer (actually doing this along a udemy bootcamp course).

It all worked just fine but now for some reason the interpreter won't move to the next block of code So it will process the machine choice section but won't move on to the winner calculation.

I have no idea what went wrong since I didn't change the code one bit. I left comments in the code so you can understand me better

Thanks for your help!

import random

print ("ROCK PAPER SCISSORS")
Human_choice = input("Human, what's your choice?").lower()

hw = "The human won!"
mw = "The machine won!"
tie = "It's a tie"

#start of machine choice
machince_choice = random.randint(1,3)
if machince_choice == 1:
    machince_choice = "Rock"
elif machince_choice == 2:
    machince_choice = "Paper"
elif machince_choice == 3:  
    machince_choice = "Scissors"
print(f"Machine plays {machince_choice}")
#end of machine choice 
#it seems like from here on it just won't process

if Human_choice == machince_choice:
    print(tie)

if Human_choice == "Rock":
    if machince_choice == "Paper":
        print (mw)
    elif machince_choice =="Scissors":
        print (hw)

if Human_choice == "Paper":
    if machince_choice == "Rock":
        print (hw)
    elif machince_choice =="Scissors":
        print (mw)

if Human_choice == "Scissors":
    if machince_choice == "Rock":
        print (mw)
    elif machince_choice =="Paper":
        print (hw)

if machince_choice == "Rock":
    if Human_choice == "Paper":
        print (hw)
    elif Human_choice =="Scissors":
        print (mw)

if machince_choice == "Paper":
    if Human_choice == "Rock":
        print (mw)
    elif Human_choice =="Scissors":
        print (hw)

if machince_choice == "Scissors":
    if Human_choice == "Rock":
        print (hw)
    elif Human_choice =="Paper":
        print (mw)

Aucun commentaire:

Enregistrer un commentaire