The aim is to create a percentage attendace calculator based on a given list of names. I was able to loop the input questions with the names in the list. However my issues lie with the following if condition which should output a 1 for each input question if the answer is y for each person in the list or a 0 if the answer n for any person in the list. The number outputs should then be added in order to obtain a precentage. Please help.
continueLooping=True
students=["Annie", "Brian", "Clare", "Danny", "Ellen"]
i=0
while i<len(students):
askuser=input(f"Is {students[i]} present?[y/n]")
i=i+1
if askuser == "y":
one = 1
print("1")
else:
one = -1
print("-1")
while one<len(students):
if askuser == "y":
one = 1
one=one+1
else:
one = -1
one=one+1
percentage=(one)/len(students)
print(percentage)
Aucun commentaire:
Enregistrer un commentaire