带字符串的for循环有什么问题?(What is wrong with this for loop with a string? [closed])
Start= 1
End= 10
change=0.5
for Start in range(Start,End,change) :
print(Start)
这段代码有什么问题? 我在学校工作,似乎无法使用字符串的for循环。
Start= 1 End= 10 change=0.5 for Start in range(Start,End,change) : print(Start)What is wrong with this code? I was working at it in school and can't seem to use the for loop with a string.
最满意答案
Python range支持浮点increment ,因此错误:
DeprecationWarning: integer argument expected, got float所以你在0.5的值需要是一个整数,你可以用数学来得到相同的输出
Start= 2 End= 21 change=1 for Start in range(Start,End,change) : print(Start*0.5)Python range wont support floating point increment, Hence the error:
DeprecationWarning: integer argument expected, got floatSo your value at 0.5 needs to be an integer, and you can use mathematics to still get same output
Start= 2 End= 21 change=1 for Start in range(Start,End,change) : print(Start*0.5)更多推荐
发布评论