def silly(n):
"""requires: n is an int > 0
Gets n inputs from user
Prints 'Yes' if the inputs are a palindrome; 'No' otherwise"""
assert type(n) == int and n > 0
for i in range(n):
result= []
elem = input('Enter something: ')
result.append(elem)
print(result)
if isPal(result):
print('Is a palindrome')
else:
print('Is not a palindrome')
如果您嘗試運行此函數,例如n = 3,爲什麼elem不會正確追加到結果?它將打印作爲新的結果列表。這消息我的isPal函數。追加到列表中
這使得現在更有意義,謝謝! – Miraclefruit
沒問題 - 如果這解決了你的問題,不要忘記勾選這個答案:) – Shadow