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