不使用列表索引:
listit = [1, 5, 3, 7] x_position = 0 result = 0 for x in listit: x_position += 1 y_position = 0 for y in listit: y_position += 1 if x_position < y_position: print(f"{x} * {y}") result += x * y print(result) print(result)