Erreur du type "too many indices for array"
Bonjour,
je commence python et j'ai une erreur que je ne comprends pas :
test[i]=binomiale(n,0.5)
IndexError: too many indices for array.
Code ci-joint :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
#################################################
#1 Fonction
def bernoulli(p2) :
# Si le chiffre aléatoire est plus grand que p,
#l'épreuve est réussi. Sinon elle à échouée
if random()<p2:
return 1
else:
return 0
################################################
#2 Fonction
def binomiale(n,p3) :
somme=0
k=0
for k in range(n):
somme+= bernoulli(p3)
return somme
#################################################
n=10
for i in range(10):
test[i]=binomiale(n,0.5) #L'erreur semble venir d'ici |
ps : l'indentation est respectée