首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >While循环打印else语句

问While循环打印else语句
EN

Stack Overflow用户
提问于 2017-06-14 17:28:12
回答 0查看 124关注 0票数 1

我的循环似乎工作正常,直到我将输入保留为空。我希望它只是循环“输入新的单词或整数”,但它正在经历循环,并输出else语句‘多字符类型’。如果有人能给我建议,我将不胜感激。

代码语言:javascript
复制
#hard code number
number=90


#whileloop
while True:
    enter_text = input("enter word or integer): ") 
        print()#loop if empty


     #check if all alpha
    if enter_text.isalpha():
        print(enter_text, "is all alphabetical characters! ")
        break


    #check<90>90   
    elif enter_text.isdigit():
        if int(enter_text) > number:
            print(enter_text, "is a large number")

        if  int(enter_text) <= number:
                print(enter_text,"Is smaller than expected")
        break


    #if conditions are not meet, multiple characters     
    else: 
        print(enter_text,'multiple character types')
EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44540733

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档