-3

Ok so I have two separate paths in my python code after a question and I need them to link together to avoid typing out the rest of my game twice and wasting space and code. image of my code

so as you can see, the last four or so lines are the same but with two different indentations. How can I make them both the same? So instead of having to write out:

print('''You carefully wrap the material around your head, wincing in pain everytime your hand bumps the wound.''')
print('''You wonder what the wound was from. It is unimportant however as the bleeding seems to be slowing.''')

Twice, I only have to write it once.

Shashanth
  • 4,995
  • 7
  • 41
  • 51

3 Answers3

1

Use a function:

def rip_and_bandage():
    print('''You carefully wrap the material around your head, wincing in pain everytime your hand bumps the wound.''')
    print('''You wonder what the wound was from. It is unimportant however as the bleeding seems to be slowing.''')
H. Kamran
  • 366
  • 2
  • 12
0

In this particular case you can give a default value for yeet_bleed. e.g.

yeet_bleed = 0
# Some input to yeet_bleed here
if bleeding_heal == '1' or yeet_bleed == '1':
    print('something')

Another suggestion for the while True loop:

while bleeding_heal not in ['1','2','3']:
    bleeding_heal = input("some text:")
Kevin Fang
  • 1,966
  • 2
  • 16
  • 31
0

Make a function call to the common function, after each path, or write your path codes in a function, and once the function returns, your common block of code is executed.

Try not to use multiple and nested if, makes the code confusing- use handle funtions- solution suggested in the link below:

What's an alternative to if/elif statements in Python?