【发布时间】:2018-07-15 20:19:21
【问题描述】:
这是我的问题:/
所以我一直在从事这个项目,但我找不到任何问题的答案......为什么我要多次输入字母 C 或 c 才能调用 c() 函数,有时甚至不工作?我的脚本正确吗?
脚本:
def c():
print ('do something')
def s():
print ('do something else')
def main():
if input() == 'S' or input() == 's':
print ('Please enter the number you want to start with:')
s()
elif input() == 'C' or input() == 'c':
print ('Please enter the number you want to check:')
c()
else:
print ('Please enter either S or C')
main()
print ('You want to Start with or Check a number? Enter S or C.')
main()
脚本结果 1:
You want to Start with or Check a number? Input S or C.
c
c
c
c
do something
脚本结果 2:
You want to Start with or Check a number? Input S or C.
c
C
c
C
Please input either S or C
You want to Start with or Check a number? Input S or C.
编辑:我很抱歉帖子的质量很差,但这是我的第一篇!
【问题讨论】:
-
欢迎来到 Stack Overflow!请edit您的帖子将源代码包含为格式化文本和您的问题的文本描述。屏幕截图是不够的。
-
input() == 'S' or input() == 's'如果不是 S,则要求输入两次。input() == 'C'如果不是 S/s,则要求第三次输入。input() == 'c'第四次询问是否不是 S/s/C。
标签: python python-3.x if-statement input