码迷,mamicode.com
首页 > 其他好文 > 详细

while用法

时间:2019-01-18 12:14:09      阅读:182      评论:0      收藏:0      [点我收藏+]

标签:password   输出   put   div   登陆   else   user   方法   输入   

while count < 10:
    count += 1  # count = count + 1
    if count == 7:
        print( )
    else:
        print(count)

count = 0
while count < 10:
    count += 1  # count = count + 1
    if count == 7:
        continue
    print(count)

循环到7输入为空

#3、输出 1-100 内的所有奇数
#方法一:
# count = 1
# while count < 101:
#     print(count)
#     count += 2
#方法二:
# count = 1
# while count < 101:
#     if count % 2 == 1:
#         print(count)
#     count += 1

#5、求1-2+3-4+5 ... 99的所有数的和
# sum = 0
# count = 1
# while count < 100:
#     if count % 2 == 0:
#         sum = sum - count
#     else:
#         sum = sum + count
#     count += 1
# print(sum)
6、用户登陆(三次机会重试)
#input 心中有账号,密码 while

i = 0
while i < 3:
    username = input(请输入账号:)
    password = int(input(请输入密码:))
    if username == kkkllppp and password == 123:
        print(登录成功)
    else:
        print(登录失败请重新登录)
    i += 1

 

while用法

标签:password   输出   put   div   登陆   else   user   方法   输入   

原文地址:https://www.cnblogs.com/li105803859/p/10286648.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!