help

Chris Angelico rosuav at gmail.com
Wed Jan 30 17:20:14 EST 2013


On Thu, Jan 31, 2013 at 8:16 AM,  <aramildaern at gmail.com> wrote:
> Hi everyone! I don't mean to intrude, but ive heard great things about this group and ive stumped myself with my python code.

Hi! As others have said, this is no intrusion, but it'd help a lot if
you posted your errors and used a more useful subject line.
Additionally, when you post, can you give some example lines from the
file? This part of your code is impossible for us to simulate:

>         fileName = sys.argv[1]
>         jadeFile = open(fileName, 'r')
>
>         for line in jadeFile:
>                 counter = counter + 1
>                 execute(line)
>
>         jadeFile.close()

But this much I can suggest:

>         i = 0
>
>         while i < len(labelList):
>                 print(labelList.keys()[i], ":", labelList.values()[i])
>                 i = i + 1

Instead of iterating with a counter, you can iterate with a Python 'for' loop.

for label,count in labelList.items():
	print(label,":",count)

It's that simple!

ChrisA



More information about the Python-list mailing list