+ 1

Recursive fonction that identify the position of an number #but it doesn't work

def position (L,x): if L=[]: return -1 elif L[0]!=x : return position(L[1:],x)

9th Nov 2017, 8:39 PM
Beautiful mind
Beautiful mind - avatar
2 Antworten
+ 1
yeah i corrected it but still not working! :(
9th Nov 2017, 9:21 PM
Beautiful mind
Beautiful mind - avatar
+ 5
What happens when you try? Do you get an error message? Undesired output? I'm not sure what all you're doing, and I'm no Python expert, but shouldn't your first expression have a == instead of =? L==[]:
9th Nov 2017, 8:43 PM
AgentSmith