检查用户名是否被使用,比较时不区分大小写
current_users = ['Amy', 'Bob', 'Cathy', 'Daisy', 'Ellen']
new_users = ['Amy', 'Bob', 'CATHY', 'DAISY', 'Grey']
current_users_lower = [user.lower() for user in current_users]
for new_user in new_users:
if new_user.lower() in current_users_lower:
print("You need make a special name.")
else:
print("The name is unused.")
打印列表中数字对应的序数
numbers = ['1', '2', '3', '4', '5', '6', '7', '8', '9']
for number in numbers:
if number == '1':
print("1st")
elif number == '2':
print("2nd")
elif number == '3':
print("3rd")
else:
print(number + "th")