Matt Newton
Matt Newton

Reputation: 63

How do I remove these apostrophes from the string

print("ENEMY Health is ", (int(ehealth), ' / ', (int(emaxHealth))), sep='')

Should look like: ENEMY Health is 100 / 100

but it looks like this: ENEMY Health is (100, ' / ', 100)

Whats the go with this?

Upvotes: 0

Views: 355

Answers (3)

Pierre Prinetti
Pierre Prinetti

Reputation: 9652

By enclosing the health ratio in brackets, you are creating on the fly a Python tuple. Calling print on that tuple will result in printing its string representation. So you have three elements enclosed in brackets and separated by commas, two of them being numbers (no quotes), and the one in the middle being a string (hence the quotes).

Your line of code could be:

print("ENEMY Health is {0} / {1}".format(ehealth, emaxHealth))

Upvotes: 2

Geen
Geen

Reputation: 9

Im more familiar with java is but I I think maybe change to quote's! print("ENEMY Health is ",(int(ehealth), "/" ,(int(emaxhealth)))) or take out quotes and apostrophies and leave the / where it is. hope this helps!

Upvotes: 0

Avinash Raj
Avinash Raj

Reputation: 174766

Remove the brackets present inside the print function.

>>> ehealth = 100
>>> emaxHealth = 100
>>> print("ENEMY Health is ",str(ehealth),' / ',str(emaxHealth), sep='')
ENEMY Health is 100 / 100

OR

>>> print("ENEMY Health is "+str(ehealth)+' / '+str(emaxHealth))
ENEMY Health is 100 / 100

OR

>>> print("ENEMY Health is {} / {}".format(ehealth, emaxHealth))
ENEMY Health is 100 / 100

Upvotes: 1

Related Questions