I want to return the index(0) from the list in the shown code but it returns None and when I tried to print index(0) it printed 1 so I want to know how to return the index
class Solution:
def lastStoneWeight(self, stones) ->int:
if len(stones) ==1:
print(stones[0])
return stones[0]
s = max(stones)
stones.remove(s)
v = max(stones)
stones.remove(v)
l = s-v
stones.append(l)
self.lastStoneWeight(stones)
list = [2,7,4,1,8,1]
s = Solution()
print(s.lastStoneWeight(list))
The print(stones[0]) is just for debgging
I tried to return the first index of the list but it returned None and I was expecting it to return the index because when I used the function print() it worked!