Python Forum
an array to count votes
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
an array to count votes
#1
i need to make a code that counts the votes from 3 candidates from 4 different places, each person from those places can vote only once. the code has to be able to:
-receive every vote and add it to the votes of the candidate
-inform about the votes obtained by each candidate
-inform about the total votes obtained between all candidates
-inform about the winner

i´ve been struggling with this for a couple days now Wall , the thing is i have to use a bidimensional array wich im unfamiliar with. i would appreciate any help, from now thanks.

also english is my second language, sorry for possible misswriting. Heart Heart
Reply
#2
Welcome to the forum, please view the links in my signature.
Larz60+ likes this post
Reply
#3
Pointing to: https://docs.python.org/3/library/collec...ns.Counter

Simple demonstration:
from collections import Counter

# using a Counter to count unique objects like str or int
# you can also add or substract Counter-objects.
result = Counter(["Trump", "Trump", "Trump", "Biden"]) + Counter(["Trump"] * 10)

print(result)
Output:
Counter({'Trump': 13, 'Biden': 1})
But it's your task to write the program.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Count Letters in a Sentence (without using the Count Function) bhill 3 5,166 Jun-19-2018, 02:52 AM
Last Post: bhill

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020