减少Python中的循环是不可能的吗? [英] Decreasing for loops in Python impossible?

查看:48
本文介绍了减少Python中的循环是不可能的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可能是错的(请让我知道,我将删除该问题),但是python似乎不会响应

I could be wrong (just let me know and I'll delete the question) but it seems python won't respond to

for n in range(6,0):
    print n

我尝试使用xrange,但也没有用.我该如何实施?

I tried using xrange and it didn't work either. How can I implement that?

推荐答案

for n in range(6,0,-1):
    print n
# prints [6, 5, 4, 3, 2, 1]

这篇关于减少Python中的循环是不可能的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆