[Ilugc] Doubt in python

  • From: lgp171188@xxxxxxxxx (Guruprasad)
  • Date: Tue, 5 Nov 2013 16:10:04 +0530

Pressed send a bit too early before completing the email.

On Tue, Nov 5, 2013 at 4:07 PM, Guruprasad <lgp171188 at gmail.com> wrote:

On Tue, Nov 5, 2013 at 3:44 PM, hari prasadh <hariprasadh89 at gmail.com> 
wrote:

dict={88:'c2process',89:'riskmgmt',95:'portal'}

'dict' is a python built-in. Not a good idea to use it to name your variable.
So something like my_dict = {88:'c2process',89:'riskmgmt

my_dict = {88:'c2process',89:'riskmgmt',95:'portal'}

Quoting the rest of the email for the completeness of the answer.

for i in reader:

...     print "dict["+i[1]+"]"

print my_dict[int(i[1])] will convert the string in the 2nd column of
the csv file to an integer and use it as a key, since your dictionary
uses integers as keys.

Thanks & Regards,
Guruprasad.

Other related posts: