Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

error on non-existent line

+2 votes
asked Mar 23 by Sam (1,310 points)
idk why python is being dumb https://onlinegdb.com/uQIa__xdr

2 Answers

0 votes
answered Mar 24 by Peter Minarik (63,200 points)
edited Mar 25 by Peter Minarik

These are dangerous questions, my friend. :)

99% of the time, we, programmers are the ones who mess up something and not the programming language or the compiler are responsible.

In your case, Python is complaining about an unexpected end of file. And in fact, Python is right.

is_palindrome(input("enter a palindrome here: ")

You start to call a function and provide its argument within parenthesis, but then you never close the parenthesis for the is_palindrome() function (only for the input() function), so Python keeps looking for this closing parenthesis on the lines below but hits end of file. So the fix is to add one more closing parenthesis at the end of the line.

Note, after this, your program still does not work correctly, there are more issues to fix.

Good luck! :)

0 votes
answered Apr 7 by userdotexe (1,340 points)

You made a small mistake my friend.

def is_palindrome(palindrome):
    # making the variables to see if the two match
    front_index=0
    back_index=-1
    # checking if they match
    while bar[front_index]==[back_index] and front_index!=bar[-1]:
        front_index+=1
        back_index-=1
    #checking if it's a palindrome based off while-loop
    if front_index==bar[-1]:
        print("it's a palindrome")
    else:
        print("nope")
# calling the function
is_palindrome(input("enter a palindrome here: ")) # You need another paranthesis

:)

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...