On 27-Oct-11 11:25, ADRIAN KELLY wrote:
Hi all, is it possible to change a dictionary list to lowercase..without having to retype? e.g. definitions={"Deprecated": "No longer in use", "Depreciation": "fall in value of an asset"} i have tried definitions=definitions.lower()
lower() is not a dictionary method, it's a string method (i.e., dictionaries have no idea how to lowercase themselves, but strings do).
So what you need to do is iterate over the list of dictionary members and re-create a new dictionary with lowercased versions of the strings (that's easier than changing the dictionary in-place, especially if you're lowercasing the keys, since keys are immutable--you'd have to delete the old one and re-store the data under the lowercased key anyway)
There are several ways to do that, including loops and list comprehensions. Does that nudge you in the right direction? If you're still stuck, let us know. --steve -- Steve Willoughby / st...@alchemy.com "A ship in harbor is safe, but that is not what ships are built for." PGP Fingerprint 4615 3CCE 0F29 AE6C 8FF4 CA01 73FE 997A 765D 696C _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor