users = ['admin','alex','eric','crystol','joji']#创建一个列表
for i in users:#遍历整个列表
if i.lower() == 'admin':#如果i的变量转换为小写后与‘admin’比对
print("ni hao guanli yuan ")
else:
print("hello " + i + " see you agange!")
print("\n")
'''5-9'''
del users[:]#删除列表中的全部元素
if users:
for i in users:
if i.lower() == 'admin':
print("ni hao guanli yuan ")
else:
print("hello " + i + " see you agange!")
else:
print("we need to find some users")
print("\n")
'''5-10'''
curren_users = ['admin','alex','eric','crystol','joji']
new_users = ['admin','bobo','pigen','top','ALEX']
for i in new_users:
if i.lower() in curren_users:
print("你输入的用户名已被占用")
else:
print("用户名可以被使用")
print("\n")
'''5-11'''
nums = list(range(1,10))
for i in nums:
if i == 1:
print(str(i)+"st")#整数+字符串时候提示错误,应该加上str() 转换
elif i == 2:
print(str(i)+"nd")
elif i == 3:
print(str(i)+"rd")
else:
print(str(i)+"th")