Help

Chris Angelico rosuav at gmail.com
Fri Jul 26 01:35:41 EDT 2013


On Fri, Jul 26, 2013 at 6:06 AM,  <tyler at 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



More information about the Python-list mailing list