zoukankan      html  css  js  c++  java
  • While循环

    1.

    age_of_oldboy = 56
    
    count = 0
    while True:
        if count == 3:
            break
        guess_age =int(input ("guess age:"))
        if guess_age == age_of_oldboy:
            print ("you got it")
            break
        elif guess_age > age_of_oldboy:
            print("think bigger!!!")
        else:
            print("think smaller!!")
        count +=1

    2

    age_of_oldboy = 56
    
    count = 0
    while count < 3:
        guess_age =int(input ("guess age:"))
        if guess_age == age_of_oldboy:
            print ("you got it")
            break
        elif guess_age > age_of_oldboy:
            print("think bigger!!!")
        else:
            print("think smaller!!")
        count +=1
    else:
         print("you have tried many times...")

     3

    age_of_oldboy = 56
    count = 0
    while count < 3:
        guess_age =int(input ("guess age:"))
        if guess_age == age_of_oldboy:
            print ("you got it")
            break
        elif guess_age > age_of_oldboy:
            print("think bigger!!!")
        else:
            print("think smaller!!")
        count +=1
        if count == 3:
            continue_confirm = input ("Do you want to cntinue keep trying..?")
            if continue_confirm != "n":
                count = 0
  • 相关阅读:
    Phone-reset
    解决ie8下h5元素兼容性的问题
    PC css_reset
    centos7 nginx@1.16.1
    centos 7
    IE兼容css3的圆角和阴影和渐变
    前端开发安全编码规范
    防抖和节流封装模块
    vue的简单实现
    vue中$forceUpdate的使用
  • 原文地址:https://www.cnblogs.com/wz123/p/9652156.html
Copyright © 2011-2022 走看看