Python中的嵌套While循环 [英] Nested While loop in Python
本文介绍了Python中的嵌套While循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是 Python 编程的初学者.我编写了以下程序,但它没有按照我的意愿执行.代码如下:
I am a beginner in python programming. I wrote the following program but it doesn't execute as I want it to. Here is the code:
b=0
x=0
while b<=10:
print 'here is the outer loop\n',b,
while x<=15:
k=p[x]
print'here is the inner loop\n',x,
x=x+1
b=b+1
有人可以帮我吗??我真的会很感激的!问候,吉拉尼
can somebody help me?? I will be grateful indeed! Regards, Gillani
推荐答案
不确定您的问题是什么,也许您想将 x=0
放在内部循环之前?
Not sure what your problem is, maybe you want to put that x=0
right before the inner loop ?
你的整个代码看起来不像 Python 代码......像这样的循环最好这样做:
Your whole code doesn't look remotely like Python code ... loops like that are better done like this:
for b in range(0,11):
print 'here is the outer loop',b
for x in range(0, 16):
#k=p[x]
print 'here is the inner loop',x
这篇关于Python中的嵌套While循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文