Python Automation third Day-python2

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.