import math
import random
a = random.random()
b = random.random()
c = random.random()
d = a*b*c
e = 14
print ("a = {0}".format(a))
print ("b = {0}".format(b))
print ("c = {0}".format(c))
print ("d = {0}".format(d))
if "e" in d:
print("Value found")
else:
print("Value not found")
问题是变量e
。
答案 0 :(得分:-1)
您应该首先将整数转换为字符串,以便像字符串一样进行搜索,例如:
if str(e) in str(d):
答案 1 :(得分:-1)
替换:
if "e" in d:
使用:
if str(e) in str(d):
演示:
>>> e=12
>>> d=45123
>>> str(e) in str(d)
True
答案 2 :(得分:-1)
您可以通过以下方式执行此操作:
list=[]
for x in range(2,d):
if d%x==0:
list.append(x)
if e in list:
print ("e is a multiplier")
else:
print("e is not a multiplier")