具有不均匀间隙的 Python 范围

标签 python python-3.x

关闭。这个问题是not reproducible or was caused by typos .它目前不接受答案。












想改进这个问题?将问题更新为 on-topic对于堆栈溢出。

1年前关闭。




Improve this question




今天我有一个python考试,问了以下问题:
给定以下代码提取,完成代码,输出为:10 7 5 .

nums = list (range (?,?,?))

print(nums)
如何使用 range 函数在 python 中获得这样的输出?

最佳答案

不确定这是否回答了问题,前提是我们可以在 ? 中填写任何语法。只要它产生结果。

  • 第一个? = 10
  • 第二? = 4
  • 第三? = -3))+(([5]
  • # nums = list(range(   ?  ,  ?  ,      ?       ))
    nums   = list(range(  10  ,  4  ,  -3))+(([5]  ))
    print(nums)
    # nums = [10,7,5]
    

    关于具有不均匀间隙的 Python 范围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62525771/

    相关文章:

    python - 这是在 DataFrame 中设置值的安全方法吗?为什么这有效?

    python - 何时建议使用 ret_val 变量?

    运行有限或无限生成器函数时出现 Python3 错误

    python - 如何使用 .translate() 从 Python 3.x 中的字符串中删除标点符号?

    python - 在 SQLAlchemy/Elixir 中选择不同的列值

    python - 当我尝试在 Tensorflow 中调整图像大小时如何修复 "TypeError: x and y must have the same dtype, got tf.uint8 != tf.float32"

    python - PyQt4 Python2 Unicode

    python-3.x - 如何识别两个数据帧之间的精确行匹配并打印其上方的行

    python - 如何安装 tensorflow_text?

    python - 由于 SSL 错误,无法使用 pip 安装 python 库