The code is correct (I think), but the output isn’t!
print ("You try to move the table.")
numbers = random.choice(list)
print ("You rolled a", numbers)
if numbers == "1" or "2" or "3" or "4" or "5" or "6" or "7":
print ("Whoops! You failed to move the table. Look, it's heavy, okay? Don't think too bad of yourself.")
elif numbers == "8" or "9" or "10" or "11" or "12" or "13" or "14":
print ("Ouch! You failed to move the table, and dropped it on your foot! That hurts...")
health = 90
print ("Your health is now", health)
elif numbers == "15" or "16" or "17" or "18" or "19" or "20":
print ("You successfully move the table. It's heavy, but you manage.")
The first random number generated was “18”, but it printed the first line — “Whoops! You failed to move the table. Look, it’s heavy, okay? Don’t think too bad of yourself.” — instead of the correct line — “You successfully move the table. It’s heavy, but you manage.” Why isn’t it printing the correct line?
Please note that this isn’t all the code inputted, just the section that has problems.
The statement list
is the name of a specific list in the code. (I googled how to use the random.choice
function.) If I should change that, please let me know.
Yes, I have imported the “random
” function.
Also, please let me know if I should show more information in order for this to make more sense.
(I’m writing a text-based adventure game! )
View comments for updated code. (Please don’t question why I put it there… )