Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Very beginner needs help
#1
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.
Reply
#2
    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 //.
Reply
#3
(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!
Reply
#4
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.
Reply


Forum Jump:

User Panel Messages

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