Code run but answer not correct ( python) -
player_number=name_to_number(name) player_number=int () # compute random guess comp_number using random.randrange() comp_number=random.randrange (0,4) # compute difference of player_number , comp_number modulo 5 rpsls_match = (player_number-comp_number)%5 # use if/elif/else determine winner if rpsls_match == 1 or 2: rpsls_winner = 'player wins!' elif rpsls_match == 3 or 4: rpsls_winner = 'computer wins!' else: rpsls_winner = 'player , computer tie!' #print "player chooses " + name # convert comp_number name using number_to_name print 'computer chooses ', number_to_name(comp_number),comp_number print 'player chooses ' , name, player_number return rpsls_winner
code run correctly did not answer want,, give me answer
computer chooses paper 2 player chooses rock 0 player wins! computer chooses lizard 3 player chooses paper 0 player wins! computer chooses spock 1 player chooses scissors 0 player wins! computer chooses paper 2 player chooses lizard 0 player wins! incorrect input computer chooses lizard 3 player chooses spock 0 player wins!
but want
player chooses rock computer chooses scissors player wins! player chooses spock computer chooses lizard computer wins! player chooses paper computer chooses lizard computer wins! player chooses lizard computer chooses scissors computer wins! player chooses scissors computer chooses spock computer wins!
rpsls_match == 1 or 2
should
rpsls_match in (1, 2)
or
rpsls_match == 1 or rpsls_match == 2
.
try evaluating 1 or 2
@ repl. answer 1
because or
returns first non-false-evaluating operand.