对于第三个elif,我试图让它检测'Numb'中是否有任何特殊字符,并且是否有重复的while循环。如何查找输入中是否有任何特殊字符
我一直在使用re.match与进口重新尝试,但它似乎并不奏效
Numb = input('Enter the number you want to find the factorial of: ')
if Numb.isalpha() == True:
print ('You can\'t find the factorial of a letter stupid! Try a digit
next time')
elif int(Numb) <0:
print ('You cannot find the factorial of a negative number')
elif Numb >=0 and Numb.isdigit() == True:
print ('::::::::::::::::' ':'*len(Numb))
print ('you have chosen', Numb)
print ('::::::::::::::::' ':'*len(Numb))
Con +=1
elif re.match("^[a-zA-Z0-9]*$", Numb):
print ('Do not enter any special characters. e.g. \' \' or \'.\'')
else:
print ('Please entar an integer that is 0 or above')
任何帮助将不胜感激,我仍然很新的这
你的输入是什么? – anupsabraham
发生了什么,你想要发生什么? – mrCarnivore
1.使用小写变量名; 2.不要使用'condition == True' – Dabiuteef