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


Groups > comp.lang.python > #51284

Re: Help

References <067018ce-ca0c-415b-a5d3-3c2f79f11e8e@googlegroups.com>
Date 2013-07-26 06:35 +0100
Subject Re: Help
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.5133.1374816945.3114.python-list@python.org> (permalink)

Show all headers | View raw


On Fri, Jul 26, 2013 at 6:06 AM,  <tyler@familyrobbins.com> wrote:
> I'm a bit new to python and I'm trying to create a simple program which adds words and definitions to a list, and then calls them forward when asked to.

One of the most important tidbits of information is: What version of
Python are you using?

> print("Welcome to Digital Dictionary V1.0!\n\n")

This looks like Python 3 style, though it would be valid Python 2 too.

>     choice = input("Type 'Entry' to add a word to the Dictionary, 'Search' to find a word, and 'Exit' to quit. ")

And I sincerely hope that this is Python 3, otherwise it would be
doing some very strange and dangerous things. However, relying on us
to guess isn't particularly safe, and works only for the major branch
of 2.x vs 3.x. The actual version you're using will be helpful.

>         while finish < 1:
>             if True:
>                 finish = 1
>                 entry = 0
>                 definition = 0

You're doing a lot with sentinel values, and it's getting a bit
confusing. Your problem here seems to be that 'finish' is never reset,
so the second time through, your loop is completely skipped. I
recommend instead that you use 'break' to exit your loops.

In a piece of somewhat amusing irony, you're here trying to implement
a dictionary. Python has an object type of that name ('dict' is short
for dictionary), which will be extremely useful here. I advise you to
explore it - it'll replace your words[] and dictionary[] lists.

ChrisA

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


Thread

Help tyler@familyrobbins.com - 2013-07-25 22:06 -0700
  Re: Help alex23 <wuwei23@gmail.com> - 2013-07-26 15:21 +1000
  Re: Help Peter Otten <__peter__@web.de> - 2013-07-26 07:27 +0200
  Re: Help Chris Angelico <rosuav@gmail.com> - 2013-07-26 06:35 +0100
  Re: Help Terry Reedy <tjreedy@udel.edu> - 2013-07-26 01:46 -0400
  Re: Help tyler@familyrobbins.com - 2013-07-26 20:40 -0700

csiph-web