<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Edit Distance &#187; Dictionary</title>
	<atom:link href="http://editdistance.com/category/python/dictionary/feed/" rel="self" type="application/rss+xml" />
	<link>http://editdistance.com</link>
	<description>by Dinesh</description>
	<lastBuildDate>Sun, 20 Jan 2013 14:07:16 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Python Dictionary with multiple values</title>
		<link>http://editdistance.com/python-dictionary-with-multiple-values/</link>
		<comments>http://editdistance.com/python-dictionary-with-multiple-values/#comments</comments>
		<pubDate>Wed, 16 May 2012 10:59:17 +0000</pubDate>
		<dc:creator>Dinesh M</dc:creator>
				<category><![CDATA[Dictionary]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Tuple]]></category>

		<guid isPermaLink="false">http://editdistance.com/?p=43</guid>
		<description><![CDATA[In Python, we cannot construct a dictionary with multiple values. However, we can construct a dictionary with multiples values by using tuple/list. Here is the example: [crayon-51a0a1eed4985/] Output: Name: personTwo &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- Height: 6     Weight: 80 Name: personOne &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- Height: 6     Weight: 75 Name: personThree &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- Height: 7     Weight: 85 &#160; Explanation: I [...]]]></description>
				<content:encoded><![CDATA[<p>In Python, we cannot construct a dictionary with multiple values. However, we can construct a dictionary with multiples values by using tuple/list.</p>
<p><strong>Here is the example:</strong></p><pre class="crayon-plain-tag">personDatabase = {&quot;personOne&quot;: (6,75),
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;       &quot;personTwo&quot;: (6,80),
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;       &quot;personThree&quot;: (7,85)}

for eachPerson in personDatabase:
&nbsp;&nbsp;&nbsp; print &quot;Name: %s\t&quot; % eachPerson
&nbsp;&nbsp;&nbsp; print &quot;-----------------&quot;
&nbsp;&nbsp;&nbsp; print &quot;Height: %d\t Weight: %d\n&quot; % personDatabase[eachPerson]</pre><p><strong>Output:</strong></p>
<p>Name: personTwo<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
Height: 6     Weight: 80</p>
<p>Name: personOne<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
Height: 6     Weight: 75</p>
<p>Name: personThree<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
Height: 7     Weight: 85</p>
<p>&nbsp;</p>
<p><strong>Explanation:</strong></p>
<p>I constructed a personDatabase dictionary with a key and multiple values in a tuple. There are two values I used here which I refer to height and weight while printing the output.</p>
]]></content:encoded>
			<wfw:commentRss>http://editdistance.com/python-dictionary-with-multiple-values/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Comparison of dictionaries using cmp() in Python</title>
		<link>http://editdistance.com/comparison-of-dictionaries-using-cmp-in-python/</link>
		<comments>http://editdistance.com/comparison-of-dictionaries-using-cmp-in-python/#comments</comments>
		<pubDate>Tue, 15 May 2012 07:47:51 +0000</pubDate>
		<dc:creator>Dinesh M</dc:creator>
				<category><![CDATA[Dictionary]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://editdistance.com/?p=36</guid>
		<description><![CDATA[cmp() is a function that we can use to compare two dictionaries. The dictionary comparison is done in the following order using cmp(): 1) size 2) key 3) value First, the size of the elements is checked, then the keys are compared and then values are compared. Syntax: [crayon-51a0a1eee1fc9/] Based on the size, key and [...]]]></description>
				<content:encoded><![CDATA[<p>cmp() is a function that we can use to compare two dictionaries.</p>
<p>The dictionary comparison is done in the following order using cmp():</p>
<p>1) size</p>
<p>2) key</p>
<p>3) value</p>
<p>First, the size of the elements is checked, then the keys are compared and then values are compared.</p>
<p><strong>Syntax:</strong></p><pre class="crayon-plain-tag">cmp(dictionary_one, dictionary_two)</pre><p>Based on the size, key and then value comparison,</p>
<p>a) If the dictionary_one is <strong>greater</strong> than dictionary_two, then <strong>1</strong> is returned.</p>
<p>b) If the dictionary_one is <strong>less</strong> than dictionary_two, then <strong>-1</strong> is returned.</p>
<p>c) If the dictionary_one is <strong>equal</strong> to dictionary_two, then <strong>0</strong> is returned.</p>
]]></content:encoded>
			<wfw:commentRss>http://editdistance.com/comparison-of-dictionaries-using-cmp-in-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
