Thread: Learning Python

  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Rep Power

    Learning Python

    Well i was looking at the hint section that they give and realize that I forgot to put quotes inside the variable.

    I'm working on a project from code academy for python. the code below is what i came up with so far. and below is the error that it gives me when I try running the script. I am completely new to the language and the programming world.

    The object of this one was to ensure that the string is not empty. Below the code is the error that it gives me. I'm still completly new to this area even though I've read that it tells you whats wrong with the code I do not completly understand it yet.

    print("Welcome to the English to Pig Latin translator!")
    name = raw_input("what's your name?")
    original = raw_input
    if len(original) > 0:
    print original
    print "empty"

    Traceback (most recent call last):
    File "python", line 4, in <module>
    TypeError: object of type 'builtin_function_or_method' has no len()
    Last edited by gib0583; October 6th, 2013 at 07:09 PM. Reason: Figure it out
  2. #2
  3. Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Aug 2011
    Rep Power
    original = raw_input

    With this statement the value of original becomes the same as the value of raw_input.

    They're both names for the same object.

    original is synonymous for the raw_input function.

    You might have meant instead to assign

    original = name
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo