2013-04-14 26 views
0

這是一個簡單的程序得到錯誤爲什麼我嘗試在Python程序在Windows上的Python IDLE

def is_palindrome_v1(s): 
    """ (str) --> bool 
    Return True if and only if s is a palindrome 

    >>> is_palindrome_v1('noon') 
    True 
    >>> is_palindrome_v1('racecar') 
    True 
    >>> is_palindrome_v1('dented') 
    False 
    """" 
    return reverse(s) == s 

def reverse(s): 
    """ (str) --> str 
    Return a reversed version of s 
    >>> reverse('hello') 
    'olleh' 
    >>> reverse('a') 
    'a' 
    """ 
    rev = "" 
    for ch in s: 
     rev = ch + rev 
    return rev 

錯誤,我得到的,當我嘗試運行

"SyntaxError: EOL while scanning string literal" 

不是從哪裏獲得肯定這個錯誤即將到來。

回答

0

你三引號字符串有一個"報價太多:

""" (str) --> bool 
    Return True if and only if s is a palindrome 

    >>> is_palindrome_v1('noon') 
    True 
    >>> is_palindrome_v1('racecar') 
    True 
    >>> is_palindrome_v1('dented') 
    False 
    """" 
------^ 
相關問題