Menu
Menu
DaniWeb
Log In
Sign Up
Read
Contribute
Meet
Search
Search
About 864 results for
key-value-pair
- Page 1
insert new line after diplaying each key value pair in javascript object
Programming
Web Development
14 Years Ago
by amby
… object. i want to display its values like after each
key
value
pair
, i want to insert new line. but i dont know… concatObject(obj) { // str = ''; // for (prop in obj) { // str += prop + "
value
:" + obj[prop] + "\n"; // } // return (str); //} function concatObject…
Dictionary -- key:value pair swap
Programming
Software Development
17 Years Ago
by sneekula
How do you best swap the
key
:
value
pair
of a dictionary?
add new key-value pair to a dict
Programming
Software Development
14 Years Ago
by checker
… last few lines are wrong I want to add new
key
-
value
pair
to a dict list1 = {'joe': 11, 'john', 19} for example…
Re: add new key-value pair to a dict
Programming
Software Development
14 Years Ago
by masterofpuppets
… to simply remove line 25 You can create a new
key
-
value
pair
like this: [CODE]>>> d = {} >>>…
Re: Dictionary -- key:value pair swap
Programming
Software Development
17 Years Ago
by mawe
… swap(d): ...: new = {} ...: for
key
,
value
in d.items(): ...: if
value
in new.keys(): ...: new[
value
].append(
key
) ...: else: ...: new[
value
] = [
key
] ...: return new ...: In [8]: d…
Not able to read the first key value pair in map
Programming
Software Development
9 Years Ago
by can-mohan
…issues. (1) I am not able to read first
key
and
value
pair
record from snmp.json file in my map, it just… start reading after first record. (2) After reading the
value
…{ std::string line; vector <string>v; int
key
=0,
value
=0; std::map<std::string, std::string> props…
Accessing key value combination in JavaScript
Programming
Web Development
8 Years Ago
by rouse
… many sets I have and how to access each
key
value
pair
in javaScript. response[ {"RECORD_NUM":967,"…quot;}, ] It seems that response.length() gives the
value
of the number of fields. And using generates an error… = response.DATE_FIELD[0]; How would I get the
value
of the second field in the first row of response…
Re: Dictionary -- key:value pair swap
Programming
Software Development
17 Years Ago
by Ene Uran
In case of the capital:state
pair
I did it this way: [php]def swap_dictionary(original_dict): temp_dict = {} …
Re: add new key-value pair to a dict
Programming
Software Development
14 Years Ago
by woooee
…; def _init_(self): ## 'name' is redundant since it is the
key
of the dictionary ##self.name = "" self.age = 0….sqrtage = 0 def print_all(name_dict): for name in name_dict: ## each
key
in the dictionary print name, name_dict[name].age, name_dict[name…
Re: add new key-value pair to a dict
Programming
Software Development
14 Years Ago
by snippsat
…'} {'age': 22, 'name': 'lise'} ''' #when we call (
key
)worker1.name we are getting the (
value
) print worker1.name ''' jon ''' print sqrt(worker2…
Re: add new key-value pair to a dict
Programming
Software Development
14 Years Ago
by masterofpuppets
…'} {'age': 22, 'name': 'lise'} ''' #when we call (
key
)worker1.name we are getting the (
value
) print worker1.name ''' jon ''' print sqrt(worker2…
Re: add new key-value pair to a dict
Programming
Software Development
14 Years Ago
by masterofpuppets
… woooee mentioned, since you're using the name as the
key
in the dictionary, you don't need it in the…
Re: key value pair array
Programming
Web Development
9 Years Ago
by Priti_P
I tried like `$array = array_combine($database,$skill_type_count);` but it gives me only last
value
and without
key
value
as below: Array ( [] => Array // NO
KEY
HERE?? ( [SKILL_ID] => 117 [weight] => 1 ) )
Re: key value pair array
Programming
Web Development
9 Years Ago
by DJBirdi
Since both your arrays are setup as `$
key
=> $
value
` pairs, you have to explicitly tell `array_combine` which array to use for what. This should work: $array = array_combine(array_keys($database), array_values($skill_type_count));
Re: Not able to read the first key value pair in map
Programming
Software Development
9 Years Ago
by NathanOliver
Change `props.emplace(std::
pair
<string,string>(tokena,tokenb));` to `props.insert(std::
pair
<string,string>(tokena,tokenb));`
Re: Not able to read the first key value pair in map
Programming
Software Development
9 Years Ago
by tinstaafl
…::getline(tokens,tokena,':'); std::getline(tokens,tokenb); props.emplace(std::
pair
<string,string>(tokena,tokenb)); //cout<<translation_table…
Re: insert new line after diplaying each key value pair in javascript object
Programming
Web Development
14 Years Ago
by amby
i have solved it by putting <br /> instead of "\n" in concatObject method like this: return strArray.join("<br />");
Re: Dictionary -- key:value pair swap
Programming
Software Development
17 Years Ago
by vegaseat
If you like to practice with list comprehension, you can use this ... [code=python]def swap_dictionary(original_dict): return dict([(v, k) for (k, v) in original_dict.iteritems()]) [/code]
Re: Dictionary -- key:value pair swap
Programming
Software Development
17 Years Ago
by sneekula
Thank you, what would happen to a swap if I had a dictionary with duplicate values like this: d = {'a': 1, 'b': 1, 'c':1, 'd':99}
Re: add new key-value pair to a dict
Programming
Software Development
14 Years Ago
by checker
Thank you very much master, interesting. All you did was removing that append line (which is undefined for dict). woooee, thank you for this re-write. I have a few questions: 1. why is name redundant? 2. what is name.lower? Where did the "lower" come from? Thanks.
Re: add new key-value pair to a dict
Programming
Software Development
8 Years Ago
by Veera_1
can't we append something to a dictionary??
Re: add new key-value pair to a dict
Programming
Software Development
8 Years Ago
by Gribouillis
> can't we append something to a dictionary?? No, a python dictionary does not have an `append()` method. A dictionary is not an ordered data structure, unless you are using a `collections.OrderedDict()` instance.
Re: print array with key value pair
Programming
Web Development
9 Years Ago
by Priti_P
so sorry, it was simple: foreach ($array as $
key
=> $
value
) { if (is_array($
value
)) { foreach($
value
as $test) echo($test)."<br>"; } else { echo($
value
); echo "<br><br>"; } }
how to copy value of one map to value of another map?
Programming
Software Development
11 Years Ago
by jalpesh_007
… instance of program, i want to change the
value
in temp, remove some
key
value
pair
and after some processing i want to again… get original
value
of remaining
key
from m1. So my problem…
Id and value pairs
Programming
Web Development
14 Years Ago
by jrw89
…Doe, jane@example.com etc... var
value
= form.elements[element].
value
; // Build a
key
/
value
pair
e.g. "firstname":"…;Jane" etc... data.
key
=
value
; } JsonToServer.formData = data…
how to insert value at specified key from one Hashmap to another hashmap
Programming
Software Development
11 Years Ago
by jalpesh_007
…execution both map will contain
key
from 1 to 20 and mapped
value
with it. Means
key
value
pair
are same in both …map. After some processing i modify
value
in temp …(key3, aa5); } } but it will also modify the
value
in map-m1, As i m not performing any operation…
Autocompleteextender in Text box with key-value pair
Programming
Web Development
14 Years Ago
by Gaurav@17
… three and enter the
key
word again...the search work fine but when I select any
value
the Text box is…(); } document.getElementById('<%=this.Hidden1.ClientID%>').
value
= userValues; //Assigning the hidden
value
to text box document.getElementById('<%=this.TxtProject…
Re: Autocompleteextender in Text box with key-value pair
Programming
Web Development
14 Years Ago
by mikev2
Hi Gaurav, I'm quite new to this too - and I'm trying to do a similar thing. I'm not sure if this is a good idea or not - but you could compare the number of commas in the text field and the hidden field? If they match, then add the new
value
on the end; else if one is zero, then set equal to the new
value
. Something like that?
Re: Autocompleteextender in Text box with key-value pair
Programming
Web Development
14 Years Ago
by reach_yousuf
Hi Just try to make the hidden text box empty before u fill it up again. [code] document.getElementById('<%=this.TxtProject.ClientID%>').
value
= ' ' //Assigning the hidden
value
to text box document.getElementById('<%=this.TxtProject.ClientID%>').
value
= userValues; [/code] Mark as solved it it helps you!!!
Re: Not able to read the first key value pair in map
Programming
Software Development
9 Years Ago
by can-mohan
Thnaks for your replay, but my compiler doesn't support emplace.
1
2
3
15
Next
Last
Search
Search
Forum Categories
Hardware/Software
Recommended Topics
Programming
Recommended Topics
Digital Media
Recommended Topics
Community Center
Recommended Topics
Latest Content
Newest Topics
Latest Topics
Latest Posts
Latest Comments
Top Tags
Topics Feed
Social
Forums
Top Members
Meet People
Community Functions
DaniWeb Premium
Newsletter Archive
Markdown Syntax
Community Rules
Developer APIs
Connect API
Forum API Docs
Tools
SEO Backlink Checker
Legal
Terms of Service
Privacy Policy
FAQ
About Us
Advertise
Contact Us
© 2024 DaniWeb® LLC