algzander
algzander

Reputation: 11

Trying to make a counter that will have its output multiplied by some fixed value

I'm trying to make a counter that will have its output multiplied by some fixed value; the code is below:

from pygears.lib import qrange, mul
qrange(10) | mul(2)

The error I'm getting is this one:

TypeMatchError: [0], Queue[Uint[4], 1] cannot be matched to Number
       - when matching Tuple[Uint[2], Queue[Uint[4], 1]] to Tuple[{'a': Number, 'b': Number}]
       - when deducing type for argument "din"
       - when instantiating "mul"

Upvotes: 0

Views: 41

Answers (1)

Robert Boscacci
Robert Boscacci

Reputation: 71

Not sure what pygears is, but you're looking for:

A counter that will have its output multiplied by some fixed value

So here you go:

# Choose your fixed value
fixed_value = 42

# Choose lower and upper bounds
left, right = 0, 5

# Multiply each index by fixed value
output_values = [i * fixed_value for i in range(left, right)]

print(output_values)

Output: [0, 42, 84, 126, 168]

Does that help?

Upvotes: 0

Related Questions