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

  • Home
  • SEARCH
  • 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 7801067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:50:11+00:00 2026-06-02T00:50:11+00:00

I am defining a function def update(dictionary,key,value): dictionary[key] = value # if i do

  • 0

I am defining a function

def update(dictionary,key,value):
    dictionary[key] = value
   #  if i do print dictionary... it still shows the original value?

I want to update the input dictionary in the main call

So this is the main function i wrote:

def update_mapping(mapping_dict,check_word,solution_word):
    #print "here "
    #new_mapping_dict = {}
    for i,ele in enumerate(check_word):
        if mapping_dict.has_key(ele):
            if mapping_dict[ele] == "*":
                mapping_dict[ele] = solution_word[i]

                print ele, solution_word
    print mapping_dict,check_word,solution_word

Basically I am inputting a misspelled word and then misspelled word has some mapping..
I do that mapping in the dictionary..
Like

 mapping_dict ={"a":"x"...."s":"*"...}

So all the known alphabets whose mapping have been found have a legit key value alphabet pairs..
for the alphabets for which I havent found the right mapping, I am replacing them with “*”
and I am finding them with some algorithm (inverted index)

And as i found those, I want to update my dictionary?

  • 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-02T00:50:12+00:00Added an answer on June 2, 2026 at 12:50 am
    >>> test = {"test": 1}
    >>> def update(dictionary,key,value):
    ...     dictionary[key] = value
    ... 
    >>> update(test, "test", 2)
    >>> test
    {'test': 2}
    

    Your problem must be elsewhere – this works.

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

Sidebar

Related Questions

I'm defining a function in PowerShell and trying to call it as shown below.
In R , I'm defining the function lengths depending on the value of a
Given the python function: def MyPythonMethod(value1, value2): # defining some variables a = 4
Is it possible to call a function without first fully defining it? When attempting
Can 2 or more equations defining a function in Haskell share the same where
If I run the function below before defining it, I will get this error...
Does defining functions inside a loop affect performance? Like var doSomething = function(element){ $(element).whatever();
Let's say I have a function def odd_or_even n if n%2 == 0 return
I have a simple function to do simple math operations. If I call this
I want to combine combine fields from an input .csv file for output to

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.