How to delete last item in list?

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

    If you have a list of lists (tracked_output_sheet in my case), where you want to delete last element from each list, you can use the following code:

    interim = []
    for x in tracked_output_sheet:interim.append(x[:-1])
    tracked_output_sheet= interim
    

提交回复
热议问题