Résolu probleme d'indentation Python

Inscription
7 Juillet 2015
Messages
304
Réactions
162
Points
1 016
Bonsoir j'ai un probleme d'indentation a la deuxieme ligne de mon code , quelqu'un peut-il m'aider ? Merci

 

Spixz

This Is Us
Premium
Inscription
11 Décembre 2011
Messages
3 197
Réactions
847
Points
20 453
C'est normal, il faut intenter le contenue de ta fonction comme ceci :
Code:
def test():
   print("test")

Et non comme ça :
def test():
print("test")

c'est comme si ta fonction ne contenais rien.

Code correct :
Code:
def moving_average (tab, N) :
    S = 0     
    R = T   
    for i in range (N,len(T)) :
        S == 0
        for k in range (i-N+1,i):
            S == S+T[k]
    R[i] == S/N
    for i in range (1,N-1):
        R[i] ==  T[i]
    return  R[i]

y = []
 
for x in range(1000):
    y += [math.cos(x/100 + random.random())]
 
graphic.plot(y)
graphic.plot(moving_average(y,10))
graphic.show()
 
Haut