#20519: python 為什麼錯??? 一直說讀到EOF


youngyoung (06 蘇昱揚 306)


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")

#20521: Re:python 為什麼錯??? 一直說讀到EOF


iamgond (gond)


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"

如果有誤請糾正

#20523: Re:python 為什麼錯??? 一直說讀到EOF


youngyoung (06 蘇昱揚 306)


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"

如果有誤請糾正

過了,謝謝