您的位置:首页 > 其它

list and dict

2011-09-29 14:26 239 查看
'''
Created on 2011-9-29

@author: xgzhao
'''
list2 = list('foo')
print list2
list2.remove('f')
print list2

print [i*2 for i in range(8) if i%2 == 0]

print [i for i in reversed(range(8))]

fdict = dict((['x', 1], ['y', 2]))
print fdict

tdict = {}
print tdict
print fdict.keys(), fdict.values(), fdict.items()
'''
Created on 2011-9-29

@author: xgzhao
'''
db = {}

def newUser():
prompt = 'login desired: '
while True:
name = raw_input(prompt)
if db.has_key(name):
prompt = 'name taken, try another'
continue
else:
break
pwd = raw_input('password: ')
db[name] = pwd

def oldUser():
name = raw_input('login: ')
pwd = raw_input('password: ')
passwd = db.get(name)
if passwd == pwd:
print 'Welcome back ', name
else:
print 'login incorrect'

def showmenu():
prompt = """
(N)ew User Login
(E)xisting User Login
(Q)uit
Enter choice = """
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: