I am writing a program in python3 to keep score of N number of players and am having trouble getting the score to be input correctly from each player. the code in bold is where I am having an issue. The loop closes after I enter the score for the first contestant and i for some reason equals 3 instead of increasing from 0 to 1. I would like 'i' to update as the loop continues so that the code to get scores continues until each player has been scored.
I don't know how to get the result I want. Am I using the wrong loop statement?
I have tried while, if and for statements.
I just started coding Tuesday so any help is greatly appreciated.
import csv
from array import *
names = []
con = int(input("Number of Contestants: "))
maxSurfers = con #number of surfers
while len(names) < maxSurfers:
name = input(" Enter your Name: ")
names.append(name)
print("Contestants")
print(names)
else:
print("Thank You for Participating!\n")
print("Sign up is now closed")
**score = array('f', [])
i = 0
n = int(input("Number of Waves for "+names[i]+": "))
while i != n:
x=float(input("Enter score for each wave: "))
score.append(x)
i = i + 1
print(i)
print("Winner being decided.")**
outputs:
Number of Contestants: 2
Enter your Name: frank
Contestants
['frank']
Enter your Name: bart
Contestants
['frank', 'bart']
Thank You for Participating!
Sign up is now closed
Number of Waves for frank: 3
Enter score for each wave: 9.6
Enter score for each wave: 7.8
Enter score for each wave: 7.2
3
Winner being decided.
Aucun commentaire:
Enregistrer un commentaire