<[EMAIL PROTECTED]> wrote: > hi, > I am doing example of address book.when user enter stop and presses > enter my loop should stop.But there is some prob in my loop.It is > accepting \r after pressing Enter key.How do i check end of input : > addressbook={} > name = raw_input("Enter Name (stop to Finish)") > > name = EnterAddress(addressbook) > > ShowAddress(name, addressbook) > > def ShowAddress(name, addressbook): > name = raw_input("Enter Name for Address ") > print "Address of %s is %s" %(name,addressbook[name]) > > def EnterAddress(addressbook): > while name != "stop": > entry = raw_input("Enter the address") > addressbook[name]=entry > name = raw_input("Enter Name (Leave blank to Finish)") > return name
Add 'name' to the arguments of EnterAddress, just as you correctly have it in ShowAddress. Alex -- http://mail.python.org/mailman/listinfo/python-list