首页 > 编程语言 > 详细

python 2nd 条件控制之while语句

时间:2021-08-30 13:52:43      阅读:25      评论:0      收藏:0      [点我收藏+]

实例

while True:
    s = input(Enter something : )
    if s == quit:
        break
    print(Length of the string is, len(s))
print(Done)

实例

while True:
    s = input(Enter something : )
    if s == quit:
        break
    else:
        print(Length of the string is, len(s)) 
print(Done)

 

 

实例  猜数字  while语句

number = 23
running = True
while running:
    guess = int(input(Enter an integer : ))
    if guess == number:
        print(Congratulations, you guessed it.)
# 这将导致 while 循环中止
        running = False
    elif guess < number:
        print(No, it is a little higher than that.)
    else:
        print(No, it is a little lower than that.)
else:
        print(The while loop is over.)
# 在这里你可以做你想做的任何事
print(Done)

 

python 2nd 条件控制之while语句

原文:https://www.cnblogs.com/xsgg/p/15196558.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!