Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need to write a program count() that takes a list of names of candiates up for

ID: 3644286 • Letter: I

Question

I need to write a program count() that takes a list of names of candiates up for election and then asks the user to enter the name of one of the canidates repeatedly as a parameter. When the person using the program enters an empty string, the function will print for all the names that are on the ballot the number of votes that the canidate received. If the user types a name that doesn't exist in the list, then the vote is recorded for 'Other' canidate. CAPS also don't matter so however the user enters it should work. When a blank name is typed, then the function needs to stop and report all the totals of the vote count.

This is an example of how it should go.
* I know this code isn't complex, but I can't figure out how to exactly write it, But I know it's super simple, I gave it a try but struggled*

>>> count(['Henry', 'John', 'Paul')
Enter a vote: Henry
Enter a vote: JOHN
Enter a vote: paul
Enter a vote: PaUL
Enter a vote: Haris
Enter a vote: john
Enter a vote: PAUL
Enter a vote:
Therewere 3 votes for Paul.
Therewere 2 votes for John.
There was 1 vote for Henry.
There was 1 vote for Other.

Explanation / Answer

def count(names):
    votes=[]
    lnames=[]
    for n in names:
        votes.append(0)
        lnames.append(n.lower())
    votes.append(0)

    done=False

    while not done:
        vote=raw_input("Enter a vote: ")
        vote=vote.lower()
        if vote=="":
            done=True
            continue
        if vote in lnames:
            place=lnames.index(vote)
            votes[place]=votes[place]+1
        else:
            votes[len(votes)-1]=votes[len(votes)-1]+1
   
    for i in range(len(names)):
        tense="was"
        vtense="vote"
        if votes[i]>1:
            tense="were"
            vtense="votes"
        print "There",tense,votes[i],vtense,"for",names[i]+"."
    tense ="was"
    vtense="vote"
    if votes[len(votes)-1]>1:
        tense="were"
        vtense="votes"
    print "There",tense,votes[len(votes)-1],vtense,"for","Other."