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

    法一:

    !/usr/bin/env python
    #_*_ coding:utf-8 _*_
    count = 0
    while True:
      print("count:",count)
      count +=1
      if count == 100:
        break

    法二:

    #!/usr/bin/env python
    #_*_ coding:utf-8 _*_
    age_of_jack = 26
    count = 0
    while count <3:
      guess_age = int(input("guess age:"))
      if guess_age == age_of_jack:
        print("yes,you got it.")
        break
      elif guess_age >age_of_jack:
        print("think smaller...")
      else:
        print("think bigger!")
      count +=1

    else:

      print('you have tried too many times...fuck off.')

    法三:

    #!/usr/bin/env python

    # -*- coding: utf-8 -*-
    age_of_jack = 23
    count = 0
    while count <3:
      guess_age = int(input('guess age:'))
      if guess_age == age_of_jack:
        print('yes,you got it.')
        break
      elif guess_age >age_of_jack:
        print('think smaller...')
      else:
        print('think bigger!')
      count +=1
      if count == 3:
        countine_confirm = input('do you want to keep guessing?')
        if countine_confirm !='n':
          count = 0

  • 相关阅读:
    redis搭建集群
    redis搭建主从
    redis与python交互
    redis数据操作篇
    redis配置篇
    node 淘宝镜像
    java 深copy
    springmvc配置访问静态文件
    centos 启动 oracle
    List 分隔多次执行 且在同一个事物当中
  • 原文地址:https://www.cnblogs.com/qlqqlq/p/8687682.html
Copyright © 2011-2022 走看看