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

    1、

    >>> a = {}
    >>> while a != "quit":
        a = input("please input an incredient:")
        if a != "quit":
            print(f"{a} will be added!!")
    
            
    please input an incredient:apple
    apple will be added!!
    please input an incredient:abc
    abc will be added!!
    please input an incredient:quit

    2、

    >>> tag = True
    >>> while tag:
        a = input("please input an incrident: ")
        if a != "quit":
            print(f"{a} will be added!!")
        else:
            tag = False
    
            
    please input an incrident: apple
    apple will be added!!
    please input an incrident: 100
    100 will be added!!
    please input an incrident: quit

    3、

    >>> while True:
        a = input("please input an item:")
        if a == "quit":
            break
        else:
            print(f"{a} will be added!!")
    
            
    please input an item:apple
    apple will be added!!
    please input an item:100
    100 will be added!!
    please input an item:quit
  • 相关阅读:
    在单向链表中删除指定的key
    双向链表反转
    单向链表反转
    认识异或运算
    二分查找
    插入排序
    冒泡排序
    选择排序
    go 语言环境安装
    欧几里得算法
  • 原文地址:https://www.cnblogs.com/liujiaxin2018/p/14222746.html
Copyright © 2011-2022 走看看