【发布时间】:2020-04-16 16:04:51
【问题描述】:
我正在尝试制作一个程序,它显示 40 个值的列表,选择 4 个值,并显示该值是否在列表中可用,是否低于 40 个值,如果高于 40 个值则不可用。 程序代码如下:
# -*- coding: utf-8 -*-
list = list(range(1,41))
print(list)
listValues = []
for i in range(1,5): #1,2,3,4
value = int(input("Write the value" +str(i)+":")) #Write the value 1
listValues.append(value)
print(listValues)
for value in listValues:
for item in list:
encoutered = []
[] != True or False
if encoutered:
print("Value " + str(value) + " encountered.")
else:
print("Value " + str(value) + " not encoutered.")
但是当遇到值时我无法接收,只有当它没有遇到并且仍然包含在那些没有遇到的值中遇到的值。
【问题讨论】: