Error Problems with: [Ahoy! (or Should I Say Ahoyay!)]


#1




Every time I run this code I get an error saying "SyntaxError: invalid syntax". I don't know what I can do to fix this error.


This code should print the phrase "Pig Latin" out.


userWord = raw.input("Please enter a letter.").lower()

def check():
    if(userWord == ""):
        print "The input you entered was empty, please re-enter your input"
        userWord()
    elif(userWord ==  !["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]):
        print "You did not enter a letter. Please re-enter your input"
        userWord()
    else:
        return True

def pigLatin():
    print "Pig Latin"

pigLatin()


#2

Did you mean to write, raw_input()?

This is not a defined function. Try,

def userWord():
    return raw_input("Enter a word to translate: ")

Of course this deviates from the instructions so I hope you have passed the exercise already and are just experimenting now. If not, go back and follow the instructions closely.

Python has a built-in function for checking content. If you have not yet reached that lesson, then put this on hold, and go back to the beginning, start over and you should get to this by about the fourth or fifth lesson.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.