How to delete last item in list?

后端 未结 7 751
再見小時候
再見小時候 2021-01-30 06:08

I have this program that calculates the time taken to answer a specific question, and quits out of the while loop when answer is incorrect, but i want to delete the last calcula

7条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-30 06:27

    you should use this

    del record[-1]
    

    The problem with

    record = record[:-1]
    

    Is that it makes a copy of the list every time you remove an item, so isn't very efficient

提交回复
热议问题