<br><br><div class="gmail_quote">On Thu, Oct 27, 2011 at 2:25 PM, ADRIAN KELLY <span dir="ltr">&lt;<a href="mailto:kellyadrian@hotmail.com">kellyadrian@hotmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">




<div><div dir="ltr">
<br>Hi all,<br>
is it possible to change a dictionary list to lowercase..without having to retype?<br>
e.g. definitions={&quot;Deprecated&quot;: &quot;No longer in use&quot;, &quot;Depreciation&quot;: &quot;fall in value of an asset&quot;}<br> <br>
i have tried definitions=definitions.lower()<br>
 <br>
regards<br><font color="#888888">
adrian<br><br>                                               </font></div></div>
<br>_______________________________________________<br>
Tutor maillist  -  <a href="mailto:Tutor@python.org">Tutor@python.org</a><br>
To unsubscribe or change subscription options:<br>
<a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/mailman/listinfo/tutor</a><br>
<br></blockquote></div>There is a string method called lower so &#39;Bob&#39;.lower() will return &#39;bob&#39;<br><br>You can&#39;t alter the keys in a dictionary because they are immutable -- they can&#39;t be changed<br>
<br>But you can loop through your dictionary, make new keys lowercase and copy the values associated with each key<br><br>like this:<br><br>&gt;&gt;&gt; new_d = {}<br><br>&gt;&gt;&gt; for d in definitions:<br>...   new_d[d.lower()] = definitions[d]<br>
... <br>&gt;&gt;&gt; new_d<br>{&#39;deprecated&#39;: &#39;No longer in use&#39;, &#39;depreciation&#39;: &#39;fall in value of an asset&#39;}<br>&gt;&gt;&gt; <br><br><br><br clear="all"><br>-- <br>Joel Goldstick<br><br>