[Python] I'm trying to code a recursive program but the problem is that my code is not...

Discussão em 'Python' iniciado por Stack, Maio 13, 2025.

  1. Stack

    Stack Membro Participativo

    def unique_recursive(A,index=0):
    index==0
    if not A:
    return -1

    if index>=len(A)-1:
    return

    if index+1>len(A)-1:
    temp=[]
    temp.append(A[index])

    if A[index]!=temp[index]:
    temp.append(A[index])
    return unique_recursive(A,index+1)

    print(unique_recursive([1,2,3,4,5,2,5,1,3]))


    I am a beginner and i am having problems with this code,it is a recursive function, i want it to return a list with unique elements without using any loops. The input is a list that has repeated items but i now want the program to return the list without any repition of elements

    Continue reading...

Compartilhe esta Página