【发布时间】:2014-02-06 00:06:29
【问题描述】:
这是我尝试过的:
my_tickets = [ [ 7, 17, 37, 19, 23, 43],
[ 7, 2, 13, 41, 31, 43],
[ 2, 5, 7, 11, 13, 17],
[13, 17, 37, 19, 23, 43] ]
def lotto_matches(xs, my_tickets):
xi = 0 # could be used to pick specific things from lists
yi = 0 # could be used to pick specific things from lists
result = []
for i in my_tickets: # List of lists
for x in xs: # Picks
if my_tickets[i] == xs[x]: #Not sure what my if statement is suppose to be
result.append() # I don't know what goes in the parenthesis
print (result)
return (result)
lotto_matches([42,4,7,11,1,13], my_tickets)
我正在尝试编写一个函数,该函数接受一张票和一张平局的列表,并返回一个列表,说明每张票上的正确选择数。
它应该返回[1,2,3,1],但我的输出完全错误。
我该怎么做?
【问题讨论】:
标签: python list function for-loop nested