while.py

来自「简明python,一本很不错的书」· Python 代码 · 共 23 行

PY
23
字号
#!/usr/bin/env python
# Filename: while.py

number=23
running=True

while running:
	guess=int(raw_input('Enter an integer : '))

	if guess==number:
		print 'Congratulations, you guessed it.'
		running=False # this causes the while loop to stop
	elif guess<number:
		print 'No, it is a little higher than that'
	else:
		print 'No, it is a little lower than that'
else:
	print 'The while loop is over.'
	# Do anything else you want to do here

print 'Done'

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?