List loop
words= ' Marry,lily,joker '
For i in words: #每次从list里边拿一个值过来给i
Print (i)
Results:
M
A
R
R
Y
,
L
I
L
Y
,
J
O
K
E
R
lists=[' Zhang Flow ', ' inside and out ', ' Newang ', ' Kiki ']
# for #循环在循环可迭代对象的时候, every time the loop is inside each element
For name in lists:
If type ==lists: #判断类型 to determine if it belongs to lists
For I in Name:
Print (i)
Print (name)
Results:
Flow
Anti-
Newang
Qi Qi
Practice:
#注册
#输入账号密码
#如果账号存在的, the hint has been registered, and if it does not exist, let him register
#不能为空
#用户名长度6-12
#最多输入3次
all_user=[' Niuhanyang ', ' Poon ', ' Zhang San ', ' Li 4,435,345 ', ' 123456 ']
# print (len (all_user)) #取个数, length
For I in range (3):
Username=input (' Please enter account: '). Strip ()
If Len (username) >5 and len (username) <13:
If All_user.count (username) >0:
Print (' User name already exists ')
Else
Print (' Register Now ')
Break
Else
Print (' username length is not legal! Length between 6-12! ‘)
Else
Print (' failed, too many times ')
Python Automation third Day-python2