Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python

Mikkel Bielefeldt
Mikkel Bielefeldt
3,227 Points

Why doesn't the code just show?

So I've been watching some videos, and then to you know remember everything I learn, I try to build my own stuff. What I'm doing is trying to make a program that's asking for delivering information and more, and then for not making so much code I made a function in another document, and then tried to import it, and that is successful but then when I run the code it just says "function valid_names at 0x109584158" instead of actual printing the code wanted.

Here is the program where the function is in.

def valid_names(name):
    their_name = input("What is your name? ")
    if len(name) < 1:
        print("Minimum characters is 1.")
    elif name == float or int:
        print("Unvalid character.")

And here is the actual program.

from actualfunction import valid_names

# This program will take your adress, phone number and more, so it'll know where to deliver the package
# Then it'll say when it's expected to get delivered, and of course when it has been delivered.
def printing_names(valid_names):
    print(valid_names)

printing_names(valid_names)

I know some other ways to make this work, but I'm trying to put a lot of code into a small space, instead of writing lines of lines of code.

1 Answer

Dave StSomeWhere
Dave StSomeWhere
19,822 Points

Valid names is a function and you are just printing the function object.

If you want to pass the execution of the function to another function then you need to include the parenthesis. Then you can debug the additional issues and learn from there (e.g. actualfunction inputs into their_name but never uses that variable and you are comparing an input string to the classes float and int when you probably want to compare the type).

Try:

# just used bill for the argument since your function requires it
printing_names(valid_names('bill'))