Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Technical Interview Prep: Python Basics Basic Python Take Me Out To The Ball Game

Leslio McKeown
seal-mask
.a{fill-rule:evenodd;}techdegree
Leslio McKeown
Python Development Techdegree Student 9,441 Points

technical interview prep: Python basic

i can't seem to find out why it keeps saying incorrect

formatting.py
city = ("Kansas ")
teamname = ("City Royals. ")

def cheer(city, teamname):
    return ("Let's go, ", city, teamname, "Let's go!")

1 Answer

Asher Orr
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Asher Orr
Python Development Techdegree Graduate 9,410 Points

Hi Leslio! When I ran your code in the challenge, I saw this error message:

AssertionError: ("Let's go, ", 'Kansas City', 'Royals', "Let's go!") != "Let's go, Kansas City Royals. Let's go!" : 
Uh oh, I didn't get the correct string returned. It should have been 'Let's go, Kansas City Royals. Let's go!'

The program is looking for this exact string:

"Let's go, Kansas City Royals. Let's go!"

Whereas your code is returning this:

"Let's go, ", 'Kansas', 'City Royals', "Let's go!"

I would wrap your entire return statement in one quotation mark, and I would use {curly brackets} to format the city and team name in your statement. Like this:

def invitation(day, address):
    return("I'm having a party on {} this week. You should come! My address is {}.".format(day, address))

That way, your arguments won't have quotation marks around them when your function is returned (and you'll have an exact match.)

PS- you don't have to define the city and teamname before you write out the function. When you click "Check Work" on the challenge, the Treehouse Program calls your function and passes in arguments (you just don't see it.)

It does this:

def invitation(day, address):
    print("I'm having a party on {} this week. You should come! My address is {}.".format(day, address))


invitation("Tuesday", "123 Main Street")
#^ It calls your function and passes in the arguments. It uses "Kansas City" for the city and "Royals" for the teamname. That's why you see that team specifically in the error message.
Asher Orr
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Asher Orr
Python Development Techdegree Graduate 9,410 Points

You're welcome! I'm glad you're all set. No worries about forgetting, either! It happens to everyone (even the senior devs experience it.)

Also, don't forget to mark "best answer" on my response. That way others will know that you've been helped, and they won't waste time by clicking on the question.