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 Python Basics (2015) Logic in Python Product

Aurelie Sacoman
Aurelie Sacoman
723 Points

Can we use .format for return call ?

Hello Everyone,

For the excercice product.py, we need to create a definition product with 2 arguments and to multiple their return.

I get a good response using : def product(name1, name2): return name1 * name2

I was wondering, could we not use format to do that? I tried it but doesn't sounds to work.

def product(name1, name2): return("{} * {}").format(name1, name2)

Maybe I am not writing it correctly or this doesn't work with return?

thanks everyone

product.py
def product(name1, name2)"
    return name1 * name2 

1 Answer

You are sooooo close! :laughing:

You just typed a " double quote instead of a : colon.

Your code

def product(name1, name2)"  <------- Error is here. You used a double quote instead of a colon!
    return name1 * name2 

Complete code

def product(name1, name2):    # <------- Fixed! Yay!
    return name1 * name2 

I hope this helps. :grin:

~Alex