0

正如主题所暗示的,我正在尝试从一个列表中获取整数(元组)并使用 pop 函数将它们添加到另一个列表中

这是我到目前为止所拥有的,并且坚持这样做。

loga = [(912, "Message A1") , (1000, "Message A2") , (988, "Message A3") , (1012, "Message A4") , (1002, "Message A5")]

logb = [(926, "Message B1") , (1008, "Message B2") , (996, "Message B3") , (1019, "Message B4") , (1100, "Message B5")]

logc = [(1056,"Message C1") , (1033, "Message C2") , (999, "Message C3") , (1054, "Message C4") , (1086, "Message C5")]

logs = [loga, logb, logc]

def find_lowest_i(logs):
    for i in range(len(lst)):
        log = lst(i)

if len(log) > t = log[0][0]

    if i==0 or t < lowest_t
    lowest_i = i
    lowest_t = t

return i
4

1 回答 1

1
loga = [(912, "Message A1") , (1000, "Message A2") , (988, "Message A3") , (1012, "Message A4") , (1002, "Message A5")]

logb = [(926, "Message B1") , (1008, "Message B2") , (996, "Message B3") , (1019, "Message B4") , (1100, "Message B5")]

logc = [(1056,"Message C1") , (1033, "Message C2") , (999, "Message C3") , (1054, "Message C4") , (1086, "Message C5")]

logs = [loga, logb, logc]
final=[]
for log in logs:
    for tup in log:
        final.append(tup[0])
lowest_number=min(int(x) for x in final)
return lowest_number

这应该为您解决问题,它通过遍历列表,将数字附加到列表,然后使用带有函数的列表推导loga,logb,logc来获得最低数字来工作。logsfinalmin()

于 2012-07-09T03:13:03.903 回答