On Wed, 25 Dec 2013 16:17:27 +0800, Amrita Kumari <amrita....@gmail.com> wrote:
I tried these and here is the code:


f=open('filename')
lines=f.readlines()
new=lines.split()

That line will throw an exception.
number=int(new[0])
mylist=[i.split('=')[0] for i in new]


one thing I don't understand is why you asked to remove first two
items from the list?

You don't show us the data file, but presumably he would ask that because the first two lines held different formats of data. Like your number= line was intended to fetch a count from only line zero?


and is the above code alright?, it can produce
output like the one you mentioned:
{1: {'HA2': 3.785, 'HA3': 3.913},
 2: {'H': 8.85, 'HA': 4.337, 'N': 115.757},

The code above won't produce a dict of dicts. It won't even get past the exception. Please use copy/paste.

--
DaveA

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to