添加列表列表的第二个元素

时间:2016-08-02 02:56:07

标签: python list sum element

我想添加每个列表的总赌注。我一直在这里搜索2个小时但是无法得到它:

inputs = []

while True:

    add_selection =raw_input("Would you like to add a selection?")
    if add_selection == "Yes":

        selection = raw_input('Horse: ')
        print selection

        stake = float(raw_input('Stake: '))
        print stake

        odds = float(raw_input('Odds: '))
        print odds

        result = (raw_input('Result: '))
        if result == "Win":
            print stake * odds
            winnings = stake * odds
        elif result == "Lose":
            print 0
        elif result == "Refund":
            print stake

        book = raw_input('Book: ')
        print book

        my_list=[selection,stake,odds,result,book]

        **sum([my_list(1) for my_list in inputs])**

        inputs.append(my_list)



        def looks_good(inputs):
            for i in inputs:                                                
              print i
    elif add_selection == "No":
        break

    looks_good(inputs)

我尝试了我突出显示的行,它给了我一个错误。我考虑过将my_list附加到桩号+来自迭代的赌注,然后保留一定数量的赌注,但我不知道我会怎么做。

谢谢!

0 个答案:

没有答案