Shortening code in "2. Same Name" flow control challenge

After completing the challenge 2. Same Name it says that you can shorted the function body code (lines 2-4) to just ONE line. I feel like I’m missing something, and there are no further hints.

def same_name(your_name, my_name): if (your_name == my_name): return True return False print(same_name("Colby", "Colby")) # should print True print(same_name("Tina", "Amber")) # should print False

Do you have a link to the project/challenge?

Not sure I can manage a hint but what does an if require in the expression and what is that you want returned in the end?


I want:
if my_name and your_name are the same, then True is returned
if they aren’t the same I want False returned

It runs like I want it (outputting True and then False), but I’m unsure as to how I can shorten lines 2-4 to just one line.

How do you find out if they’re the same? How would the actual program deal with this, a specific type perhaps? Or, in short, what is your_name == my_name in the program?

1 Like

Hey guys!
I am a new entrant in coding and i find it rather difficult to learn the Python coding language.
what did you guys do for you to get along with the computer system?

A question like that probably warrants an entire thread. The basic answer is, practice and more practice. Even for lucky folks who take to programming like ducks to water there’s nothing that beats actually using the language, for most of us the answer is probably just more practice :rofl:. If you need more info/dicussion consider a new question on the forums.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.