0

I am taking a course from Georgia Tech and I have spent all my evening trying to figure this out and I havent been able to do so. My task is as follows:

Write a function called my_TAs. The function should take as input three strings: first_TA, second_TA, and third_TA. It should return as output the string, "[first_TA], [second_TA],#and [third_TA] are awesome!", with the values replacing the variable names.

For example, my_TAs("Sridevi", "Lucy", "Xu") would return the string "Sridevi, Lucy, and Xu are awesome!".

Hint: Notice that because you're returning a string instead of printing a string, you can't use the print() statement -- you'll have to create the string yourself, then return it.

My function returns "Joshua are awesome" instead of all three variables names. I tried this

result = str(first_TA), str(second_TA), str(third_TA) + "are awesome!" 

but didn't work.

def my_TAs(first_TA, second_TA, third_TA): result = str(first_TA) + " are Awesome!" return result first_TA = "Joshua" second_TA = "Jackie" third_TA = "Marguerite" test_first_TA = "Joshua" test_second_TA = "Jackie" test_third_TA = "Marguerite" print(my_TAs(test_first_TA, test_second_TA, test_third_TA)) 
1
  • Python uses + to combine strings not commas e.g. first_TA + second_TA + third_TA + "are awesome!". I think you've confused the print() syntax of print(s1,s2,s3) with s1+s2+s3. Commented Nov 10, 2021 at 2:10

2 Answers 2

1

You can use f-Strings to accomplish this:

def my_TAs(first_TA, second_TA, third_TA): return f"{first_TA}, {second_TA}, and {third_TA} are awesome!" test_first_TA = "Joshua" test_second_TA = "Jackie" test_third_TA = "Marguerite" print(my_TAs(test_first_TA, test_second_TA, test_third_TA)) 

Output:

Joshua, Jackie, and Marguerite are awesome! 
Sign up to request clarification or add additional context in comments.

Comments

0

Use + instead of ,

def my_TAs(first_TA, second_TA, third_TA): result = str(first_TA) + ", " + str(second_TA) + ", and " + str(third_TA) + " are Awesome!" return result first_TA = "Joshua" second_TA = "Jackie" third_TA = "Marguerite" test_first_TA = "Joshua" test_second_TA = "Jackie" test_third_TA = "Marguerite" print(my_TAs(test_first_TA, test_second_TA, test_third_TA)) 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.