Python 比较列表,看答案是低还是高

Python 比较列表,看答案是低还是高,python,list,if-statement,comparison,Python,List,If Statement,Comparison,第一部分产生 average = ['2 is the average for mark a', '1 is the average for mark b', '1 is the average for mark c', '2 is the average for mark d', '1 is the average for mark e', '1 is the average for mark f',

第一部分产生

    average = ['2 is the average for mark a', 
       '1 is the average for mark b', 
       '1 is the average for mark c',
       '2 is the average for mark d', 
       '1 is the average for mark e', 
       '1 is the average for mark f', 
       '1 is the average for mark g', 
       '1 is the average for mark h', 
       '1 is the rainfall average for mark i',
       '1 is the average for mark j']
z = [1.2423] 
然后,代码的第二部分生成

    average = ['2 is the average for mark a', 
       '1 is the average for mark b', 
       '1 is the average for mark c',
       '2 is the average for mark d', 
       '1 is the average for mark e', 
       '1 is the average for mark f', 
       '1 is the average for mark g', 
       '1 is the average for mark h', 
       '1 is the rainfall average for mark i',
       '1 is the average for mark j']
z = [1.2423] 
我现在正试图将平均值的结果与z列表进行比较,并得出一个结果。基本上

if the integer value for a is greater than z then print greater than
if the integer value for b is less than z the print less than   
if the integer value for c is greater than z the print greater than.
有没有一种方法可以简化我的代码,这样它就可以比较所有的平均值,而不必为每个平均值手动键入if语句?即比较所有平均值,如果平均值小于或大于一行,则打印


谢谢。这是我今天的最后一个问题

您在这里提供的“几乎没有”信息是您问题的解决方案。此外,一些进一步的研究也不会误入歧途。你会到达那里的。坚持下去

average = [a list of your data averages]
z = 1.2423 # z variable doesn't need to be a list, just an int


for i in average:
   if int(i) > z:
       print "greater than"
   elif int(i) < z:
       print "less than"
   else:
       print "equal to z"
average=[数据平均值列表]
z=1.2423#z变量不需要是列表,只需要一个int
就我而言,平均而言:
如果int(i)>z:
打印“大于”
elif int(i)
>z=1.2423
>>>[1,1,2,1,1,2,2]]
[‘小于’、‘小于’、‘大于’、‘小于’、‘小于’、‘大于’、‘大于’]

如果您正在运行2.x,则方括号中的数学可以替换为
cmp(x,z)

您是否尝试过for循环?您的问题很难理解。第一段代码与任何事情都有什么关系?在您最后一个块的伪代码中,
a
b
c
是什么?为什么您的第二个
z
值是一个单元素列表,它是否与您在上一个块中找到的
z
变量有任何关联?