I have:
if (a[i] == 1) {
howMany[1] += 1;
}
else if (a[i] == 2) {
howMany[2] += 1;
}
else if (a[i] == 3) {
howMany[3] += 1;
}
else if (a[i] == 4) {
howMany[4] += 1;
}
else if (a[i] == 5) {
howMany[5] += 1;
}
else if (a[i] == 6) {
howMany[6] += 1;
}
else if (a[i] == 7) {
howMany[7] += 1;
}
else if (a[i] == 8) {
howMany[8] += 1;
}
else if (a[i] == 9) {
howMany[9] += 1;
}
I want to replace it with something like:
if (a[i] == 1 || a[i] == 2 <-- etc) {
howMany[i] += 1;
}
But that doesn't work. Anybody has a clue? This is C++, but I've experienced the same issue in Python, so I don't think it's a language issue but rather just a general problem.