[Python] Invalid indice in Python array

Discussão em 'Python' iniciado por Stack, Agosto 25, 2025.

  1. Stack

    Stack Membro Participativo

    I don't understand why my program keep returning

    only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`)
    and integer or boolean arrays are valid indices


    I obviously have an integer in my array but it still give me the same error. I think this problem is pretty simple but I don't understand.

    my program and the error :

    def Mandelbrot(c):
    z=0
    zn = 0
    i = 0
    boo = True
    while boo == True and i < 50:
    if abs(zn) < 100:
    zn = z**2 + c
    boo = True
    z = zn
    i = i+1
    else :
    boo = False
    return i

    print (Mandelbrot(-2+1j*(-1.5)))

    import math
    import numpy
    import matplotlib.pyplot as plt
    from IPython.display import display_image
    T=numpy.ndarray(shape=(500,500,3))
    lig = -2
    col = -1.5
    while lig <=1:
    while col <= 1.5:
    c = lig + 1j * col
    v = Mandelbrot(c)
    print(v)
    if v < 50:
    u = False
    else:
    u = True
    print(int(u))
    T[lig][col]=[v]
    lig = lig + 0.001
    col = col + 0.001

    display_image(T)

    Continue reading...

Compartilhe esta Página