- 论坛徽章:
- 0
|
#!/urs/bin/python
contact = {}
contact_list = []
select = ['1.insert','2.delete']
for i in select:
print i
print 'what\'s your choise:'
get = raw_input('1 or 2')
if get == 1:
test = 1
while test==1:
contact['name'] = raw_input("please input name: ")
contact['phone'] = raw_input("please input phone number: ")
contact_list.append(contact.copy())
go_on = raw_input("continue?\n")
if go_on == "yes":
pass
elif go_on == "no":
break
test = 0
else:
print "you didn't say no\n"
elif get == 2:
test = 1
while test == 1:
num = raw_input("what's num do you want to delete:")
for contact in contact_list:
print "%d: name=%s" % (num, contact['name'])
print "%d: phone=%s" % (num, contact['phone'])
answer = raw_input('do you want to delete the message? y/n')
if answer == y:
for i in contact_list:
if i == num:
contact_list.remove(i)
break
test = 0
else : pass
else :
print 'again'
i = 1
for contact in contact_list:
print "%d: name=%s" % (i, contact['name'])
print "%d: phone=%s" % (i, contact['phone'])
i = i + 1 |
|