Python Forum
Stop if statement from running
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Stop if statement from running
#1
im knew to python and have started work on a small project

import random
strength = random.randint(1,100)
health = random.randint(1,100)
energy = random.randint(1,100)
Text1= 'Your strength is '
Text2= 'Your health is '
Text3= 'Your energy is '
Text4= 'You took '
Text5= ' damage'
Text6= 'your health is now '
Text7= 'your energy is'
damage = random.randint(1,20)


print (Text1 + (str(strength)))
print (Text2 + (str(health)))
print (Text3 + (str(energy)))
print ('You see a beast before you what are your actions')

action = input ('Fight or Run')


if action =='Fight' or 'fight':
    print ('You Fought')
    print (Text4 + (str(damage)) + Text5)


if action =='Run' or 'run':
    print ('you ran')
    print (Text7 + (str(energy-20)))
but when i run this code it gets to the points where it asks fight or run. If i choose fight it works perfectly fine but if i choose run it still does the fight sequence and then the run sequence and i do not know how to fix this

(i know my code isnt the best but i understand it)
Reply


Messages In This Thread
Stop if statement from running - by KieranPage - May-05-2020, 03:41 PM
RE: Stop if statement from running - by tonytech - May-05-2020, 04:01 PM
RE: Stop if statement from running - by stullis - May-05-2020, 04:04 PM
RE: Stop if statement from running - by Yoriz - May-05-2020, 04:10 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  If/Else If Statement Not Running new_coder_231013 5 1,709 Dec-10-2021, 10:16 AM
Last Post: new_coder_231013
  May i ask how i can stop my coding running christing 4 2,576 Oct-03-2019, 12:25 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020