[Tutor] WindowsSE/Python User Need Help With Dictionaries

2Canadians 2canadians@nppo.net
Thu, 30 Aug 2001 10:54:05 -0400


This is a multi-part message in MIME format.

------=_NextPart_000_000B_01C13142.16310B40
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I am working on a type of menu program using Python.  I have created a =
menu and want a user to be able to input names which would go into a =
dictionary.  I have created a dictionary and can't get the input to add =
another unit to the dictionary.  It will only take the last entered =
value.  If you have a hard time understanding this, here is a sample(not =
verbatum):

import blah

def menu1():
    getConstantValue1=3Draw_input("BLAHBLAH")
    getConstantValue2=3Draw_input("BLAHBLAH")
    GetAmount=3Dinput("BLAHBLAH")
    while GetAmount>0:
        getNameList=3Draw_input("BLAH")
        dictionary=3D{"A":getConstantValue1 "B":getConstantValue2,       =
                 "List":getNameList}  #THIS IS PART OF THE DICTIONARY =
NOT A NEW LINE!!
        GetAmount=3DGetAmount - 1
    print dictionary{}
print menu1()

Thanks,
Specs

------=_NextPart_000_000B_01C13142.16310B40
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>I am working on a type of menu program =
using=20
Python.&nbsp; I have created a menu and want a user to be able to input =
names=20
which would go into a dictionary.&nbsp; I have created a dictionary and =
can't=20
get the input to add another unit to the dictionary.&nbsp; It will only =
take the=20
last entered value.&nbsp; If you have a hard time understanding this, =
here is a=20
sample(not verbatum):</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>import blah</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>def menu1():</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;=20
getConstantValue1=3Draw_input("BLAHBLAH")</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;=20
getConstantValue2=3Draw_input("BLAHBLAH")</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;=20
GetAmount=3Dinput("BLAHBLAH")</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; while=20
GetAmount&gt;0:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
getNameList=3Draw_input("BLAH")</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
dictionary=3D{"A":getConstantValue1 "B":getConstantValue2, =
&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "List":getNameList}&nbsp; #THIS IS PART =
OF THE=20
DICTIONARY NOT A NEW LINE!!</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
GetAmount=3DGetAmount - 1</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; print =
dictionary{}</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>print menu1()</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Specs</FONT></DIV></BODY></HTML>

------=_NextPart_000_000B_01C13142.16310B40--