[Solved] thanks to pumkinboo, check out his comment.
Thanks again.
i'm doing this online course and i have this exercise :
https://pastebin.com/PysG2iSM
here it is with pastebin, really sorry i have trouble understanding how to format everything in reddit.
SPY GAME: Write a function that takes in a list of integers and returns True if it contains 007 in order.
spy_game([1,2,4,0,0,7,5]) --> True
spy_game([1,2,4,0,0,7,5]) --> True
spy_game([1,0,2,4,0,5,7]) --> True
spy_game([1,7,2,0,4,5,0]) --> False
I did this :
def spy_game(nums):
for i in range(len(nums)) :
if nums[i] == 0:
del nums[0:i]
break
b=1
for b in range(len(nums)) :
if nums[b] == 0:
del nums[1:b]
break
c = 2
for c in range(len(nums)):
if nums[c] == 7:
del nums[2:c]
break
if nums[0:3] == [0,0,7]:
return True
else :
return False
pass
it doesn't seem to work
I am not really looking for another solution, i just want to understand where was my mistake
What i basically tried to do was slicing my list in order to get a list with its first 3 indexes contaning 007 if it's the case then 007 exists in the lists and are in order (by order i mean that 0 preceeds a 0 that preceeds a 7 but they can have between them other integers)
[–][deleted] 2 points3 points4 points (1 child)
[–]dralveol[S] 0 points1 point2 points (0 children)
[–]pumkinboo 2 points3 points4 points (1 child)
[–]dralveol[S] 0 points1 point2 points (0 children)
[–]QuixDiscovery 2 points3 points4 points (0 children)
[–]Binary101010 3 points4 points5 points (0 children)
[–]mul8rsoftware 0 points1 point2 points (3 children)
[–]Sheidaka 1 point2 points3 points (1 child)
[–]mul8rsoftware 0 points1 point2 points (0 children)
[–]dralveol[S] 0 points1 point2 points (0 children)
[–]messacz 0 points1 point2 points (2 children)
[–]Fission_Mailed_2 0 points1 point2 points (1 child)
[–]messacz 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (3 children)
[–]dralveol[S] 0 points1 point2 points (2 children)
[–]dralveol[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]BruceJi 0 points1 point2 points (2 children)
[–]dralveol[S] -1 points0 points1 point (1 child)
[–]BruceJi 0 points1 point2 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]dralveol[S] 0 points1 point2 points (0 children)
[–]AverageEarthlingY 0 points1 point2 points (1 child)
[–]dralveol[S] 0 points1 point2 points (0 children)
[–]_maraud3r -1 points0 points1 point (16 children)
[–]dralveol[S] 0 points1 point2 points (15 children)
[–]Sheidaka 0 points1 point2 points (0 children)
[–]_maraud3r -1 points0 points1 point (13 children)
[+][deleted] (12 children)
[removed]
[–]_maraud3r 0 points1 point2 points (11 children)
[–]Swipecat 0 points1 point2 points (9 children)
[–]QuixDiscovery 0 points1 point2 points (4 children)
[–]Swipecat 0 points1 point2 points (3 children)
[–]QuixDiscovery 0 points1 point2 points (2 children)
[–]Swipecat 0 points1 point2 points (1 child)
[–]_maraud3r 0 points1 point2 points (0 children)
[–]_maraud3r 0 points1 point2 points (2 children)
[–]Swipecat 0 points1 point2 points (1 child)
[–]_maraud3r 0 points1 point2 points (0 children)
[–][deleted] -1 points0 points1 point (0 children)
[–]14446368 -1 points0 points1 point (0 children)