Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python text fight: printing on one line

Tags:

python

I am having a problem on line 37 where I try to type a bunch of print statements on one line. One to tell you something, one with a choice statement and another with the variable enemy11. How could I print all that on one line?

Also, with the random choice, say it chooses to punch, how can I detect that so I can take it away from your health? So it chooses punch. It recognizes it punched and takes away punch from your HP.

hp=100
enemy1=100
enemy2=200
boss=500
punch=10
kick=20
fatality=99999999

attacks = ['kick', 'punch', 'fatality']
from random import choice


from time import sleep

print("Welcome to Ultimate Fight Club Plus")
sleep(1)
print("What is your name?")
name=raw_input("> ")
print("Good luck"), name
sleep(1)
print("Choose your opponent")
enemy11=raw_input("> ")
print("You chose"), enemy11
sleep(1)
print("his health is"), enemy1
sleep(1)
print("Fight!")
while enemy1>1:
        print("You can kick or punch")
        fight1=raw_input("> ")
        if fight1=="punch":
                enemy1 -= punch
                print("You punch him in the face")
                sleep(1)
                print("His health is now"), enemy1
                sleep(1)
                print(enemy11) print choice(attacks) print("You")
        if fight1=="kick":
                enemy1 -= kick
                print("You kick him.")
                sleep(1)
                print("His health is now"), enemy1
print("You win!")
like image 984
Narks Avatar asked Nov 29 '25 12:11

Narks


1 Answers

I am new to Python too. Try this:

print(enemy11, choice(attacks), "You")
like image 143
Turb0247 Avatar answered Dec 01 '25 01:12

Turb0247