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 trialreza sajadian
718 Pointsfunction to lower upper reverse and titlecase the string into a tuple
Hi. I cant figure out what part of my code is going wrong. Here it comes:
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?
string = "python quizes are fine" string_list = [] def split(string): string_list = string.split() return string_list
def uppercased(string_list): uppered = string_list.upper() return uppered
def lowercased(string_list): lower = string_list.lower() return lower
def titlecased(string_list): titlecased = string_list.title() return titlecased
def reverse(string_list): reverse = string_list[::-1] return reverse
def stringcases(string):
a = uppercased(string_list) b = lowercased(string_list) c = titlecased(string_list) d = reverse(string_list) target = tuple(a, b, c, d) return target
# 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?
string = "python quizes are fine"
string_list = []
def split(string):
string_list = string.split()
return string_list
def uppercased(string_list):
uppered = string_list.upper()
return uppered
def lowercased(string_list):
lower = string_list.lower()
return lower
def titlecased(string_list):
titlecased = string_list.title()
return titlecased
def reverse(string_list):
reverse = string_list[::-1]
return reverse
def stringcases(string):
a = uppercased(string_list)
b = lowercased(string_list)
c = titlecased(string_list)
d = reverse(string_list)
target = tuple(a, b, c, d)
return target
2 Answers
Chris Freeman
Treehouse Moderator 68,441 PointsThere are two errors in stringcases()
. The statements should use the passed parameter string
instead of string_list
. Also, tuple()
takes 1 argument, but 4 are given. You can create the tuple without the function:
def stringcases(string):
a = uppercased(string)
b = lowercased(string)
c = titlecased(string)
d = reverse(string)
target = (a, b, c, d)
return target
Mike Tribe
3,827 Pointsdef Stringcases(astring):
return astring.upper(), astring.lower(), astring.title(), astring[::-1]