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 trialfransestak
1,942 PointsBummer where's stringcases()?
Okay so I have this code here and I would like to know what I'm doing wrong
# 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?
def stringcases(string):
string = "Fischer Fritz fischt frische fische"
a = string.upper()
b = string.lower()
c = string.title()
e = string[-1:-36:-1]
f = a, b, c, d, e
return f
2 Answers
Carlos Federico Puebla Larregle
21,074 PointsYou are returning a variable named "d" inside that tuple that doesn't exist. And there's no need to create the string inside the function, you are receiving it as a parameter You could do it without all the variables:
# 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?
def stringcases(str_value):
return (str_value.upper(), str_value.lower(), str_value.title(), str_value[::-1])
I hope that helps a little bit
Perry Adkins
8,413 PointsI received the same message initially after pasting my code from my ide pycharm, but was solved by typing the code manually into the Challenge.
"""python
def stringcases(my_string): new_string = my_string.upper(), my_string.lower(), my_string.title(), my_string[::-1] return new_string
"""
Markdown is not wanting to format, so remember to not just copy and paste this code - format /indent where required.