Pyglatin


#1

Hi Guys,
I'm guessing it is something very simple that I am failing at here, but it is clearly beyond my simple mind.

I am on the lesson that confirms a user defined string was entered.

my code

print 'Welcome to the Pig Latin Translator!'

raw_input('enter a word')

original = raw_input

if len(original) > 0:
print original
else:
print 'empty'

I get the error
Traceback (most recent call last):
File "python", line 8, in
TypeError: object of type 'builtin_function_or_method' has no len()


#2

So the answer was straigh forward, but the confusion came from how the code is moved from one less to another stage.

When I refered to
original = raw_input

I should of actually entered a variable after

original = raw_input(' enter some text')

When I then called the length of original in the if statement it was able to return a value


#3

@asparkes

I want you to do me a favor, go to the IDE or Labs, now enter in the following.

Python Function Code:

def a_function(data=1):
    if data != 1:
        return data ** 5
    else:
        return data ** 2

a_function()
a_function(4)

Ok, once you complete this task get back to me and tell me what you think is going on.

Ask these questions while you preform this.

  1. Where did the data go once you used the function?
  2. How can you use the data once the function executes?

I believe you will find the answers you need after this little exercise, and if not feel free to ask again, I will provide what help I am able.