do this in idle in python
Aamir Carver
Spencer Sparks
MA 7 65494 101827
VA 4 424941 909315
PA 8 1179896 564695
OK 6 420691 758458
NY 4 2468648 2533608
The first line specify the number of candidates (2)
The next 2 lines specify the names of candidates: Aamir Carver and Spencer Sparks
The remaining lines specify information of votes for each state.
The first token (MA, VA, PA, OK, NY) specify the state abbreviation.
The second token (7, 4, 8, 6, 4) specify the number of electoral votes in the state.
The remanding tokens specify the number of popular votes for each candidate. Each tokens represent for each candidate in the state. For example of the line [MA 7 65494 101827], in MA, Aamir Carver has 65,494 votes, and Spencer Sparks has 101,827 votes. The number of votes of Spencer Sparks is more than Aamir Carver. Hence, Spencer Sparks wins 7 electoral votes in MA.Place your code in a file named candidates.py.
Here is a step by step guilelines:
Declare variables to hold:
A number of candidates.
A list of electoral vote counters for each candidate.
A list of candidate names.
Store information of votes into variables:
Use for loop to capture state and votes on each line.
Add the number of electoral votes to the candidate who has highest number of popular votes in the state
Print out the name of the candidate who wins the state
Determine the candidate who wins the overall election:
If more than one candidate that has highest number of electoral votes. Let's make this rule simple, the winner will be the candidate with lowest index.