while True:
word = input()
isPalindrome = True
for i in range(0, len(word)):
if word[i] != word [-i-1]:
isPalindrome = False
break
print("yes") if isPalindrome == True else print("no")
while True:
word = input()
isPalindrome = True
for i in range(0, len(word)):
if word[i] != word [-i-1]:
isPalindrome = False
break
print("yes") if isPalindrome == True else print("no")
try:
word = input()
except:
break
你可以試試以上方法,EOF時跳出迴圈
另一種方法是
import sys
for word in sys.stdin:<<<<<<word字串尾會多一個'\n"
如果有誤請糾正
while True:
word = input()
isPalindrome = True
for i in range(0, len(word)):
if word[i] != word [-i-1]:
isPalindrome = False
break
print("yes") if isPalindrome == True else print("no")
try:
word = input()
except:
break
你可以試試以上方法,EOF時跳出迴圈
另一種方法是
import sys
for word in sys.stdin:<<<<<<word字串尾會多一個'\n"
如果有誤請糾正
過了,謝謝