【发布时间】:2018-08-11 03:34:14
【问题描述】:
`所以我只是在做一些东西来测试我是否可以根据输入做出某些输出
每次我尝试输入答案时,这里都没有任何反应 我使用了 if elif 语句,其中包含 in range() 。 当我输入答案时什么都没有显示
from random import randint
from termcolor import colored
repeat = True
from termcolor import colored
import time
import sys
import multiprocessing
print colored("Hello, this is a program to help you practice algebraic
expressions.","magenta")
print("")
time.sleep(4)
print colored("Alright let's start with something very basic...\nWhat is x
if
2x
= 32?","magenta")
prob = int(raw_input())
if int(prob) in range (16, 16):
print colored("Well done, you got the warmup correct","yellow")
elif int(prob) in range(1, 15):
print colored("Incorrect answer try again","red")
【问题讨论】:
-
我尝试格式化您的代码,但您的缩进已关闭,请修复它。
-
您希望
if int(prob) in range (16, 16):做什么?因为它现在基本上什么都不做。 -
您的代码仅涵盖 1 到 14 之间的输入。
-
我在 (16, 16) 范围内做了,因为其他一切都失败了
-
如果您检查
range(16, 16)返回的内容,那将是有意义的。
标签: python if-statement