Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/339.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 试图使计数器的输出乘以某个固定值_Python_Pygears - Fatal编程技术网

Python 试图使计数器的输出乘以某个固定值

Python 试图使计数器的输出乘以某个固定值,python,pygears,Python,Pygears,我试图制作一个计数器,它的输出乘以某个固定值;代码如下: from pygears.lib import qrange, mul qrange(10) | mul(2) 我得到的错误是: 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': Num

我试图制作一个计数器,它的输出乘以某个固定值;代码如下:

from pygears.lib import qrange, mul
qrange(10) | mul(2)
我得到的错误是:

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"

不确定pygears是什么,但您正在寻找:

将其输出乘以某个固定值的计数器

那么,给你:

# 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)
输出:
[0,42,84,126,168]

这有用吗