Clamp tally index values in print_tally function to ensure they remain within defined limits, silencing compiler warnings