I am doing an exercise that ask me the following tasks. I am stack in the third one:
-
Create two variables called gandalf and saruman and assign them the spell power lists. Create a variable called spells to store the number of spells that the sorcerers cast.
spells = 10 gandalf = [10, 11, 13, 30, 22, 11, 10, 33, 22, 22] saruman = [23, 66, 12, 43, 12, 10, 44, 23, 12, 17]
-
Create two variables called gandalf_wins and saruman_wins. Set both of them to 0. You will use these variables to count the number of clashes each sorcerer wins.
gandalf_wins=0 saruman_wins=0
- Using the lists of spells of both sorcerers, update variables gandalf_wins and saruman_wins to count the number of times each sorcerer wins a clash.
My solution is that but is not comparing all the elements of the list, could you help me?
for spells in saruman, gandalf:
if gandalf>saruman:
gandalf_wins += 1
elif saruman>gandalf:
saruman_wins += 1
print("Total gandalf wins:", gandalf_wins)
print("Total saruman wins:", saruman_wins)
Aucun commentaire:
Enregistrer un commentaire