Python Forum
Very beginner needs help - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Very beginner needs help (/thread-8029.html)



Very beginner needs help - bostltch - Feb-03-2018

Hello! I've just, and I mean *just*, started playing with python using pycharm and I've run into a problem while trying to follow a video tutorial on coding a very basic text based game. I thought I did things correctly but apparently I did something wrong somewhere.

def fight():
    print("%s     Vs.     %s" % playerc.name, enemy.name)
    print("%s's Health: %s/%s   %s's Health: %s/%s" % playerc.name, playerc.health, playerc.maxhealth, enemy.name,
          enemy.health, enemy.maxhealth)
It keeps giving me this error and I don't know what is happening.
Error:
line 116, in fight print('%s Vs. %s' % playerc.name, enemy.name) TypeError: not enough arguments for format string

Sorry if this is painfully obvious but I don't know what it could mean, or even if I should be providing more information to solve it.


RE: Very beginner needs help - mcmxl22 - Feb-03-2018

    print("%s's Health: %s/%s   %s's Health: %s/%s" % playerc.name, playerc.health, playerc.maxhealth, enemy.name,
          enemy.health, enemy.maxhealth)
You either need to remove the / or make them //. If you need to print a slash between the names use //.


RE: Very beginner needs help - bostltch - Feb-03-2018

(Feb-03-2018, 11:35 PM)mcmxl22 Wrote:
    print("%s's Health: %s/%s   %s's Health: %s/%s" % playerc.name, playerc.health, playerc.maxhealth, enemy.name,
          enemy.health, enemy.maxhealth)
You either need to remove the / or make them //. If you need to print a slash between the names use //.

That didn't seem to change anything in this case, but I did figure out that all I needed was to encase it in more parenthesis. Silly mistake!


RE: Very beginner needs help - Larz60+ - Feb-04-2018

In PyCharm, The color of the out-most parenthesis will change color if you place your cursor just after it,
The matching parenthesis on the lift will change to the same color. If they don't match up, you either have too few or too many.

It's full of little helpers like this. I must say I j=have become so use to checking them now, that I Do it sub-consciously.