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 Python Collections (Retired) Tuples Stringcases

Griffin Kennedy
Griffin Kennedy
1,154 Points

Why will my code 'return' but not 'print'

def stringcases(my_string): my_string = tuple(['griffin', 'ava', 'reagan', 'ren']) return (my_string.upper(), my_string.lower())

Here is my code, and it works! I'm curious though, why is it when I change 'return' to 'print' the tuple?

Cheers and happy coding!

stringcases.py
# Handy functions:
# .upper() - uppercases a string
# .lower() - lowercases a string
# .title() - titlecases a string
# There is no function to reverse a string.
# Maybe you can do it with a slice?

1 Answer

Steven Parker
Steven Parker
229,744 Points

:point_right: It's important to follow the challenge instructions carefully.

Some challenges ask you to print something, others ask you to return something. You must always do what was asked to pass the challenge, even though your code might appear to work just fine if you run it directly in the workspace.

Also, are you aware that this course has been retired, and there is a newer version available?