How to delete last item in list?

后端 未结 7 678
再見小時候
再見小時候 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:35

    You need:

    record = record[:-1]
    

    before the for loop.

    This will set record to the current record list but without the last item. You may, depending on your needs, want to ensure the list isn't empty before doing this.

提交回复
热议问题