PygLatin lesson 4 calling methods


#1



Pyglatin exercise 4 Check Yourself

There are no specific error messages, but i'm confused as to why when I run this it called the method "raw_input" without me having to call it myself. Is this just automatically parsed then called when stored as a variable? Whenever i print raw_input, it prints the result of what the user typed. I'm confused


print 'Welcome to the Pig Latin Translator!'

# Start coding here!
original = raw_input("Enter a word:")
if len(original) > 0:
    print original
else:
    print "empty"


#2

I don't know if I understood you, but:

raw_input() function returns what the user typed - a string. If you call print raw_input() then the result is printed to standard output (i.e. console). If you call original = raw_input() then the result is saved as string to original variable.


#3

Oops, try again. Oops! Did you accidentally delete the variable called original?

Print Welcome to the Pig Latin Translator!'

Start coding here!

original = raw_input("Enter a word: ")
if len(original) > 0:
print str(original)
else:
print "empty"

Where did i go wrong


#4

Okay it says I've got the code right but, it says to use isalpha so the user can't enter numbers, as you can see I've entered a number. I'm curious as how to prevent the user from adding numbers,