-2

I Have the code:

self.bussTrack = Label(self.frame, text="Buss left:", self.buss, height=1, width=2, font = ("Arial",36))
self.bussTrack.pack()

The problem is with the text="Buss left:", self.buss bit where I am combining a string and a initialiser variable & python does not allow me to go ahead.

Can somebody help me point the error that print Black

Jofbr
  • 455
  • 3
  • 23
  • possible duplicate of [Python string formatting: % vs. .format](http://stackoverflow.com/questions/5082452/python-string-formatting-vs-format) – Łukasz Rogalski Apr 29 '15 at 08:10

1 Answers1

2

Try this:

self.bussTrack = Label(self.frame, text="Buss left: %s" % self.buss, height=1, width=2, font = ("Arial",36))
self.bussTrack.pack()

You can asign variables to a string with the operator %, %s means is parsed to string

In [1]: string = "hello %s" % "world"

In [2]: print string
hello world
lapinkoira
  • 8,320
  • 9
  • 51
  • 94