[Python] Python IDLE is restarting without giving me an output

Discussão em 'Python' iniciado por Stack, Fevereiro 28, 2025.

  1. Stack

    Stack Membro Participativo

    I've got a problem while i was implementing a Quick sort algorithm, just like in this case, python interpretor automaticlly restarting without returning answer . I couldn't find a more similar question than this one. As this post's been inactive since 2012 and the problem wasn't solved i decided to ask again. Here goes my code:

    #coding:utf8

    import time
    import sys
    sys.setrecursionlimit(1000000)
    x=eval(input("Type a list: "))
    start=time.time()
    L=[]
    R=[]
    L_=[]
    R_=[]
    c=0
    z=x[0]
    for j in range(1,len(x)):
    if x[j]>= z:
    R.append(x[j])
    elif x[j] <= z:
    L.append(x[j])
    def fun(x,lista,c):
    for i in range(len(x)-1):
    for j in range(i+1,i+2):
    if x<=x[j] and c!=len(x)-2:
    c+=1
    elif x>x[j]:
    lista.append(x)
    lista.append(x[j])
    x=lista[1]
    x[j]=lista[0]
    lista=[]
    c=0
    return fun(x,lista,c)
    elif x<=x[j] and c==len(x)-2:
    c=0
    return x
    fun(L,L_,c)
    fun(R,R_,c)

    print(L+[z]+R)
    end=time.time()
    print(end-start)


    The Python's version that i'm using is 3.4. As you can see, i used the sys library to increase the recursion limit, but it didn't solve my problem. I tested it, and it can sort an 'X' amount of elements that is in the range of 300>X>250, if i'm right. How can I solve this problem? Thank you, in advance.

    Continue reading...

Compartilhe esta Página