Replacing a key value in python -


I have a dictionary that looks like something

  my_dictionary = {("Today I have been trying to make it so that the user would like to change the value    P> 

  value = my_dictionary [item_1, item_2}   

I tried to use it

  def new ( ): Global choice global change option = input ("Would you like to change one value?") If preferred == "yes": change = input ("which Conditions? ") If my_dictionary: value = float (Input (" Enter value ":)) my_dictionary [change] = value else: print (" word does not exist. ")   < P> But this does not work, it takes me directly to the word 'does not exist'. I have never coded anything that is replaced by a dictionary, by adding, if someone has any ideas then I would be very much appreciative. Thank you.  

So it goes: Would you like to change a value? Yes, what are the conditions? Today it is today, the period does not exist.

It happens with and without commas, even if I just type one thing, that still does not work - it just runs on the next part of the program, especially the two words. The value must be changed so that they should be typed in the correct order.

A dictionary is basically always structured like this:

  My_dict = {key: value, key: value, key: value ... #etc, etc}   

... where each 'key' is an different The need for variables 'value' does not differ, though they are generally.

You can simply add or modify a key-value pair by typing:

  my_dict [key] = value   

... where 'key' is 'first' variable and 'value' is second.

If you're going to use tuples for keys, however, searching for a key will require an exact match if you have a dictionary with such structure: < / P>

  my_dict = {('one', 'key'): value, ('two', 'key'): other_man, .. ..etc .....}   

... and you try to say , if in 'one_my_dict' , it will return because you use it as a key Not using precise items being done Ia is

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -