python---list判断

# 判断元素
# in
usernames=["admin","test","xiaohei"]
usernames=input("username:")
if usernames in usernames:
print("输入的用户存在")
# not in 不存在
if usernames not in usernames:
print("输入的用户不存在")
#for循环
for usernames in usernames:
print(usernames)
# index 原始通过循环下标来取值
for index in range(3):#0.1.2
print(usernames[index])
posted @ 2021-09-02 10:33  王王的王  阅读(90)  评论(0)    收藏  举报