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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:45:03+00:00 2026-05-28T04:45:03+00:00

There is one question I am working on and got a very close answer…

  • 0

There is one question I am working on and got a very close answer… basically, the question is that you get two dictionaries and you have to find elements that intersect from both dictionaries and then create those elements (one same key from both dicts and two values from both dics) in a new dictionary.

a = {'A':17,'B':31,'C':42,'D':7,'E':46,'F':39,'G':9}
b = {'D':8,'E':3,'F':2,'g':5}

def intersect(a,b):
    c = set(a).intersection(set(b))
    d = {}
    for i in c:
        if i in a:
            d[i] = int(a[i]),int(b[i])
    return d

OUTPUT: {'E': (46, 3), 'D': (7, 8), 'F': (39, 2)}

I want to get the output like {‘E’: 46, 3, ‘D’: 7, 8, ‘F’: 39, 2}

How do I get rid of the parentheses around the values?

  • 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-28T04:45:04+00:00Added an answer on May 28, 2026 at 4:45 am

    The code as you have written won’t output anything at all. However, if you want to remove parentheses, then you can use this.

    str(intersect(a, b)).replace('(', '').replace(')', '')
    

    or equivalently this, which is a bit more concise and efficient

    str(intersect(a, b)).translate(None, '()')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know there's no one answer to this question, but I'd like to get
I am (very) new to WPF and I have got a question regarding that.
Hey guys, one more quick question for any experts out there. I have a
I haven't found an answer to this particular question; perhaps there isn't one. But
There is a very similar question already. One of the solutions uses code like
Simple question, but one that I've been curious about...is there a functional difference between
Unfortunately I've got a bug that I have been working on for 1 full
Firstly, I realise that this is a very similar question to this one: Which
I'm working with Core Data and got two entities (Account, Contact) where one account
I've read all recommended articles on SynchronizationContext, but there is one small question I

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.