Hello everyone.
I am very new to Python and coding in general and like many people I am learning from a text adventure game. I have figured out the basics of the text adventure and I am now trying to expand functions inside of it. The below code works with the exception of the "random" number always being the same. I have read multiple posts about this but, I just don't understand what I am doing wrong. Can anyone assist me with this? Thank-you.
I am very new to Python and coding in general and like many people I am learning from a text adventure game. I have figured out the basics of the text adventure and I am now trying to expand functions inside of it. The below code works with the exception of the "random" number always being the same. I have read multiple posts about this but, I just don't understand what I am doing wrong. Can anyone assist me with this? Thank-you.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
name = input ( "What is your name? " ) health = 10 monsterhealth = 10 import random attack = (random.randint( 0 , 4 )) while monsterhealth > 0 : action = input ( "1.Attack 2.Potion 3.Inquiry 4.Run " ).lower() if action = = "attack" : print ( "You attack dealing" ,attack, "damage" ) monsterhealth - = attack if monsterhealth < = 0 : print ( "The monster is slain." ) elif monsterhealth > 0 : print ( "The monster still has" ,monsterhealth, "health remaining. It is not intimidated." ) if monsterhealth < = 0 : print ( "You have successfully defeated the monster. " ) |