我想問用戶2個問題。他們應該回答大於0的數字,但如果他們回答像1,0或可能是0,1這仍然是一個有效的答案。如果他們用0回答這兩個問題,那麼程序將終止。我在哪裏錯了,因爲我一直堅持了一個多小時。 a = 1
b = 1
while a > 0 and b > 0:
a = float(input("Enter A: "))
b = float(input("Enter B
所以我想製作一個程序,使用def來查找階乘。 改變這一點: print ("Please enter a number greater than or equal to 0: ")
x = int(input())
f = 1
for n in range(2, x + 1):
f = f * n
print(x,' factorial is ',f)
到 的東西,使用高清
這只是給我的第一個字一個字符串,我需要沒有數字返回: def stripNonLetters(aString):
words=[]
aString=aString.lower()
for word in aString:
if word.isalpha() or word.isspace():
words.append(word)
print(words)
ret
>>> print(len.__doc__)
len(module, object)
Return the number of items of a sequence or mapping.
>>> len(os, 1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeErr