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 6618553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:50:58+00:00 2026-05-25T20:50:58+00:00

i have done the following code in order to fill a tuple with user

  • 0

i have done the following code in order to fill a tuple with user input and then add the elements of the tuple.For example giving as input 1,2 and 3,4 i have the tuple :
((1,2),(3,4)).Then i want to add 1+2 and 3+4.

This is the first part which works ok:

data=[]
mytuple=()

while True:
    myinput=raw_input("Enter two integers: ")
    if not myinput:
        print("Finished")
        break
    else: 
        myinput.split(",")
        data.append(myinput)
        mytuple=tuple(data)
print(data)
print(mytuple)

Then , try sth like:

for adding in mytuple:
    print("{0:4d} {1:4d}".format(adding)) # i am not adding here,i just print

I have two problems:
1) I don’t know how to add the elements.
2) When i add the second part of the code(the adding) ,when i press enter instead of causing the break of the program it continues to ask me “Enter two integers”

Thank you!

  • 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-05-25T20:50:58+00:00Added an answer on May 25, 2026 at 8:50 pm

    You need:

    myinput = myinput.split(",")
    

    and

    data.append( (int(myinput[0]), int(myinput[1])) )
    

    and

    for adding in mytuple:
        print("{0:4d}".format(adding[0] + adding[1]))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following code is a what I have done in order to show a
I have done the following code in JavaScript to put focus on the particular
I have just started using jQuery and although following code gets the job done,
I have done the following form <% form_for @anexo, :url => {:action => create},
How can I self-sign an iPhone application using Xcode? I have done the following:
I have done simple java app for blackberry, while building am getting following error.
.I have the following code. I am wondering why does my echo '<font color=#FF0000>'.$update_date2.'</font><br><br>'.$status.'<br>';
In my node.js app, I have the following code to get the last mark
I have the following code 1) var x = {}; x.data = {name: 'name',
I have created the following code as part of an excercise in a Ruby

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.