Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #37969

Re: help

References <cf3b0f42-a133-45df-b1c8-8291b1896878@googlegroups.com>
Date 2013-01-31 09:20 +1100
Subject Re: help
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.1235.1359584417.2939.python-list@python.org> (permalink)

Show all headers | View raw


On Thu, Jan 31, 2013 at 8:16 AM,  <aramildaern@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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

help aramildaern@gmail.com - 2013-01-30 13:16 -0800
  Re: help Ian Kelly <ian.g.kelly@gmail.com> - 2013-01-30 15:08 -0700
  Re: help Joel Goldstick <joel.goldstick@gmail.com> - 2013-01-30 17:09 -0500
  Re: help Chris Angelico <rosuav@gmail.com> - 2013-01-31 09:20 +1100
  Re: help Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-01-31 13:42 +1100
  Re: help Dave Angel <d@davea.name> - 2013-01-30 22:13 -0500

csiph-web