如果这是一个荒谬的问题,我很抱歉,但我只是学习python,我无法弄清楚这一点。 :)蟒蛇虽然循环故障
我的程序应该打印用户输入的任何状态的资本。有时它会连续工作十次,其他时间连续工作三次,然后它会在您键入状态后停止。如果我重新启动它并输入停止的状态,它将工作得很好....随机次数然后它会再次停止。我究竟做错了什么?我的代码也很糟糕?我不知道使用什么类型的代码,所以我只是在我可以开展工作的任何地方扔掉。
x = str(raw_input('Please enter a sate: '))
while x == 'Alabama':
print 'Montgomery is the capital of', x
x = str(raw_input('Please enter a state: '))
while x == 'Alaska':
print 'Juneau is the capital of', x
x = str(raw_input('Please enter a state: '))
while x == 'Arizona':
print 'Phoenix is the capital of', x
x = str(raw_input('Please enter a state: '))
while x == 'Arkansas':
print 'Little Rock is the capital of', x
x = str(raw_input('Please enter a state: '))'
有人试图帮助你的代码格式化。你应该让他们自己做,或者自己做,以便代码实际上是可读的。 – crashmstr 2012-07-24 17:33:11