Questions tagged [counter]

A Counter is a container(/bag/multiset/etc.) that keeps track of how many times equivalent values are added.

In Python:

A Counter is a dict subclass for counting hashable objects. It is an unordered collection where elements are stored as dictionary keys and their counts are stored as dictionary values. Counts are allowed to be any integer value including zero or negative counts. The Counter class is similar to bags or multisets in other languages.

http://docs.python.org/library/collections.html#collections.Counter


5262 questions
1
vote
2 answers

Plus/minus counter with plus sign on result (jquery)

I got this simple function that counts clicks (plus or minus). It works correctly. The fact is that negative values appear with the minus symbol in front of them (eg. -3), but it's not the same for positive ones. Is there a way to have positive…
1
vote
2 answers

Incrementing counter within for loop

I am having trouble properly incrementing a counter variable within a for loop. I have a variable called flag, and I want to create a new variable called num based on the values in flag. Input: …
nakedbird226
  • 77
  • 2
  • 7
1
vote
0 answers

How do I loop through an array of objects on a click event?

I am creating a quiz app where the question, answers (an array), and the correct answer are each stored in objects in an array. I am trying to attach an event listener to a button that when clicked, will increment the variable num (which is then…
55 Cancri
  • 1,075
  • 11
  • 23
1
vote
0 answers

Counter does not work on increment of 0.1 but it works on1- swift 3

I have very simple "if" statement which is part of a stopwatch, it works when the increment 1 but not 0.1! My timer has a timeInterval of 0.1 I tried to simulate this issue in a different test project which has 2 label fields and Runs button no…
Farisk
  • 83
  • 7
1
vote
3 answers

How to make time counter will continue even refresh or leave the page

I implemented a timer count on my examination page. It is just like the edmodo website. But when you're taking an exam in edmodo, even if you refresh it, the timer is still counting. On my site, if you refresh the page, the timer refresh too. What I…
Blues Clues
  • 1,694
  • 3
  • 31
  • 72
1
vote
3 answers

Reverse the order of Counter() output

Does anyone know to reverse the order of .Counter() output without doing a new list comprehension? I mean when using .Counter() on a list of 'tokenized' words from raw text, one will get, for example [('a', 100), ('b', 90), ('c', 80), ('d', 50), …
Chris T.
  • 1,699
  • 7
  • 23
  • 45
1
vote
1 answer

Jquery number counter when visible on viewport

I have a jquery number counter that starts counting on page scroll which is fine. However I'm facing 2 problems: 1- When you load the page and don't scroll the numbers stay invisible. They should start counting up when they're visible on the…
Nesta
  • 988
  • 2
  • 16
  • 44
1
vote
1 answer

collections.Counter addition error with counter of counters summation

Suppose we have code snippet as follows: from collections import namedtuple, Counter Experiment = namedtuple('Experiment', ['day', 'distribution']) LabResults = namedtuple('LabResults', ['lab_name', 'experiments_data']) lab_results_list_good = [ …
walkingpendulum
  • 190
  • 1
  • 11
1
vote
1 answer

Decimal counter JavaScript

i want to build a decimal counter in pure JavaScript. I don't know why the function doesn't want to work and count from 0.0 to 5.1. I am assuming that the problem is with Math.round - maybe it's defined in the wrong way. HTML:
petlet
  • 15
  • 1
  • 7
1
vote
2 answers

Make counter in Python

Is there a way to re-write my code using a counter? Something like: i=0, el=name[i+1]?? As code looks too long with lots of repeatings in it name = wait.until(EC.presence_of_all_elements_located((By.ID,…
Alter888
  • 41
  • 4
1
vote
2 answers

how to display years, months, weeks and days since a date

Hope you are all well, I've been struggling to find a way to display the amount of time that has passed since a specific date in years, months, weeks and days. The closest i have found, is this below but i can quite work out how to get it to display…
lionnn
  • 21
  • 5
1
vote
2 answers

How to make a counter for Ignition Designer using Python

I'm trying to do a counter that would count the amout of times when a tag (measuring conditions) is either 0 or 32767. The counter should count +1 in either case. I'm trying something like this (but I know it's a mess): def count(self): while x == 0…
Aegolius
  • 11
  • 2
1
vote
0 answers

How can I have a counter iterate through a list/array and return zero counts if condition isn't met?

I am trying to make a gradebook in python. The code reads an excel file consisting of student ID numbers, the corresponding name, and the corresponding assignment grades. The code already sums the total points and gives the correct corresponding…
user7345804
1
vote
1 answer

error : unhashable type = 'list'

I'm trying to collect errors from a file and I need to count them this is the output I need : [ error1 : 6 , error2 : 3 , error3 : 2] import os,sys import collections Data = [] errors = [] with open('out.txt') as f: for line in f: …
1
vote
1 answer

Removal of added div should result in decrease of counter and next subsequent divs should be renamed as per the order

On click of add button, I can able to add 7 divs in an order. And when I try to remove a div in between, then, sebsequent divs should be renamed/updated as per the order. My HTML
Madhukar
  • 81
  • 2
  • 7