Weird issue with label population of data result

So I have a section that populates a calculated result to three labels

See here in the design.


And this is what those labels show:-

The way I have formatted the result is the same in all three labels, see here:-

# Print the calculations in boxes on the quotation page
      self.label_subtotal.text = "£ {:.2f}".format(self.subtotal)
      self.label_totalipt.text = "£ {:.2f}".format(self.totalipt)
      self.label_totalpremium.text = "£ {:.2f}".format(self.totalpremium)

This is what the console prints for those exact same boxes :-

**Final Calculations for Premium**
**Sub Total**
Sub Total is £ 128.90
**Total IPT (Insurance Premium Tax)**
Total Insurance Premium Tax is £ 25.78
**Total Premium Including IPT)**
Total Premium is £ 154.68

This is the code for the console print statements

  print("**Final Calculations for Premium**")
      print("**Sub Total**")
      self.subtotal = self.totalage + self.totaldays + self.totalbaggage + self.totalarticle + self.totalcancellation + self.totallocation
      print("Sub Total is £ {:.2f}".format(self.subtotal))
      print("**Total IPT (Insurance Premium Tax)**")
      self.totalipt = self.subtotal * self.policyipt
      print("Total Insurance Premium Tax is £ {:.2f}".format(self.totalipt))
      print("**Total Premium Including IPT)**")
      self.totalpremium = self.subtotal + self.totalipt
      print("Total Premium is £ {:.2f}".format(self.totalpremium))

Why am I getting 5 results? I double checked the code and cut and paste the last part of the print statement, I have no other things labelled as subtotal before this. The label naming structure is the same on the others (I called it the same as the variable)

I deleted the label and re-did it, that didnt change anything

Any ideas?

Are the things that you are adding up strings or numbers?

Strings append to one another if you add them together.

I am so sorry I found the issue, it was me :roll_eyes:

No problem. Feel free to share the solution if you feel it would be helpful for others.

yes, dont start coding a line of code, which you copied and pasted, inserted a loop in it with that field(intending to re-use that code format), then walk away and forget you put it there.

3 Likes