Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9175905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:59:37+00:00 2026-06-17T16:59:37+00:00

This is part of the code I’m using – problem is detailed below. I

  • 0

This is part of the code I’m using – problem is detailed below. I am creating a simple savings calculator using Python 3.2 and tkinter on Mint Linux Nadia. Advice welcome!
Thanks
Tom

    Button(self,
           text = "Click for savings calculations",
           command = self.show_result
           ).grid(row = 6, column = 0, sticky = W)

    self.result_txt = Text(self, width = 75, height = 10, wrap = WORD)
    self.result_txt.grid(row = 7, column = 0, columnspan = 4)

def show_result(self):

    curacct = int(self.curacct_ent.get())

    isa = int(self.isa_ent.get())

    av = int(self.av_ent.get())
    avu = int(self.avu_ent.get())

    a = int(curacct + isa)
    b = int(av*avu)



    result = "Your savings total is £", (a)
    result += "and the A shares are worth £", (b)
    result += "Your total savings is £", (a+b)





    self.result_txt.delete(0.0, END)
    self.result_txt.insert(0.0, result)

# main
root = Tk()
root.title("Savings Calculator")
app = Application(root)
root.mainloop()

When I run the program the text prints fine, however it contains curly braces around the text:
{Your savings total is £} 10 {and the A shares are worth £} 25 {Your total savings is £} 35

I can’t understand why there are curly braces, but I want them gone. Does anyone know how I can do this? BTW I’m just an enthusiast learning python and loving it so far. I’ve only included the section of the code that I think is relevant.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T16:59:38+00:00Added an answer on June 17, 2026 at 4:59 pm

    With

    result = "Your savings total is £", (a)
    

    you are creating a 2-element tuple (“Your savings total is £”, a).

    Then you add new elements to the tuple with += operator.

    result_txt.insert expects a string as a second argument, not a tuple (docs), so you want to use string formatting instead:

    result = ("Your savings total is £{} "
              "and the A shares are worth £{} "
              "Your total savings is £{}").format(a, b, a+b)
    

    (see Python docs explaining format)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have this simple question please. I have this part of code which sets
I am using a three part code below: First part of the code: Basically
i using this part of code to getting docs from sphinx but sphinx Query
I think problem is with wrong using function or something else. This part of
I use this part of code to get informations from my database, using Entity
still have problem with this part of code: @interface MYAccessMp3Tags: NSObject { NSTimeInterval duration;
I'd like to rewrite this part of code using generator : basic = []
I'm using this part of code in my app : SimpleDateFormat sdf = new
I make a jquery validation, problem is here that this part from code first(first
I'm using this part of code in my system. double countA = 0.00; double

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.