I hope you can help look at the code
sheros=[['Groot',23,34,35],['Rocket',45,56,67]]
print(sheros)
newname=input('what is your name? ' )
newstat=int(input('what is the new stat? ' ))
listlength=len(sheros)
while listlength!=0:
if sheros[listlength-1][0]==newname:
sheros[listlength-1][3]=sheros[listlength-1][2]
sheros[listlength-1][2]=sheros[listlength-1][1]
sheros[listlength-1][1]=newstat
listlength-=1
else:
listlength-=1
#this is the part doing my head in!
if newname in sheros[]:
print('already here')
else:
sheros+=[[newname,newstat,0,0]]
print('added')
print(sheros)
I want it so that if the named person is already in the list it adds their new stat to the list of 3 and pushed out the oldest one (got that sorted in the while loop) but I then want to add the person to the end of the nested list if they don't appear yet (new entry), see the bit that says #this is the part doing my head in!
Is it too late, have I had too much gin?
Please help my brain hurts
Ross
Aucun commentaire:
Enregistrer un commentaire