<P>Thanks Laura !
<P>I was able to write up a little function that works. Here is what I have done so far - 
<P>def mydict(b):<BR> if len(b) > 0:<BR>            i=len(x)+1<BR>            x[i] = i<BR>            x[i] = b<BR>            <BR>        myvalues = x.values()<BR>        myx = myvalues.pop(0)<BR>        <BR>        if myx == 'TEST':<BR>            print 'Success - The 1st variable exist in the hash table >>>'<BR>            return myx<BR>        else:<BR>            print 'Try again !' 
<P> 
<P>The only problem is that I have to initialize the dictionary x manually (x={}). 
<P> 
<P>-Thanks ! <BR>
<P> <B><I>Laura Creighton <lac@strakt.com></I></B> wrote:
<BLOCKQUOTE style="BORDER-LEFT: #1010ff 2px solid; MARGIN-LEFT: 5px; PADDING-LEFT: 5px">> --0-1253328135-1044223072=:10654<BR>> Content-Type: text/plain; charset=us-ascii<BR>> <BR>> <BR>> Thanks for your quick response. <BR>> I am trying to write a function which will take a String as an argument and a<BR>> dd it to a hashtable. If the value entered is in the Hashtable then print it <BR>> or else error out. <BR><BR>This will go better if you paste in what you get out of the<BR>Python interpreter.<BR><BR>> Here is what I have written so far : <BR>> import sys <BR>> def mydict(y):<BR><BR>def makes a function. They are usually thought of like verbs.<BR>So def make_a_dict(y): might be the sort of thing that you are looking<BR>for. But I think that you simply want to in itialize your dictionary.<BR><BR>mydict={} will do this for you.<BR>> #y = raw_input ("Please enter a String: ")<BR>> if len(y) > 1:<BR>> x={}<BR><BR>Now you have make an empty dictionary. I don't think you wanted to.<BR><BR>> #x={i:y}<BR>> x[i] = i<BR>> x[i] = y<BR>> i = i+1<BR><BR>where did this i come from? remember that strings make great<BR>keys for your dictionary. Numbers do not. <BR><BR>> #return x.values()<BR>> #print x.has_key(1)<BR>> #y=x.keys()<BR>> #z=x.values()<BR>> #print y, z<BR>> print x.keys()<BR>> print x.values()<BR><BR>Now you would like to go back to raw_input, wouldn't you?<BR>But you aren't in a loop, so python is going to keep wanting<BR>the next statement. You need a way to tell it to go back to<BR>the top.<BR><BR>> <BR>> Any advice ! <BR>> -Thanks<BR><BR>It is after midnight here in Sweden. I am going to bed. Good luck,<BR>post your code with the results from the interpreter, and more<BR>specific questions. If you can manage to not sent out messages<BR>in HTML format, that would be great also.<BR><BR>Good luck,<BR>Laura Creighton</BLOCKQUOTE><p><br><hr size=1>Do you Yahoo!?<br>
<a href="http://rd.yahoo.com/mail/mailsig/*http://mailplus.yahoo.com">Yahoo! Mail Plus</a> - Powerful. Affordable. <a href="http://rd.yahoo.com/mail/mailsig/*http://mailplus.yahoo.com">Sign up now</a>