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 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,389 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,022 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,022 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.