How do i remove an item from a list and store it into a variable in python

后端 未结 2 1589
半阙折子戏
半阙折子戏 2020-12-21 11:46

so i want to remove an item from a list and store it into the variable at the same time in python. I tried a sample code like this:

rvals = []
rvals.append(\         


        
2条回答
  •  甜味超标
    2020-12-21 12:05

    Printing a removed element from the list using remove() method generally results in None. Hence, a better approach is to, first store the element to be removed and then remove it from the list.

提交回复
热议问题