【发布时间】:2014-08-11 21:28:49
【问题描述】:
我是 Python 新手,我的程序有点问题。每当我输入大于第一个数字的第二个数字时,“mCounter”应该设置为false,并且由于有一个while循环,它应该要求我再次输入位数。由于某种原因,这不会发生。每当我输入第二个大于第一个的数字时,程序就会停止。 任何帮助将不胜感激。 谢谢!
import random
#Introduction
print('Choose the mode that you would like to enter by typing the letters in the brackets')
problem = input('Multiplication(M) Addition (A) Subtraction (S) Division (D): ')
#Multiplication
if problem == 'M' or problem == 'm':
mCounter = False
while mCounter == False:
mInput1 = int(input('Enter the amount of digits you would like in the first number you are multiplying.\nThe first number should be greater or equal to the second number: '))
mInput2 = int(input('Enter the amount of digits you would like in the second factor: '))
mCounter = True
if mInput2 > mInput1:
print('The first number MUST be greater or equal to the second number. Please try again!')
mCounter == False
else:
print('nothing')
【问题讨论】:
-
删除
mCounter == False中的双等号
标签: python loops while-loop skip