Python range function

后端 未结 6 948
广开言路
广开言路 2021-02-07 05:53

Say I want to loop from 0 to 100 but with a step of 1/2. If you try

for i in range(0, 100, 0.5):
    whatever
         


        
6条回答
  •  逝去的感伤
    2021-02-07 06:38

    You'll have to either create the loop manually, or define your own custom range function. The built-in requires an integer step value.

提交回复
热议问题