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 trialIdris Abdulwahab
Courses Plus Student 2,961 PointsTupples
Hi everyone,
I'm sorry I have to bother you on Xmas day. I'm trying to breathe python as much as I can! Haha.
Please help with this code challenge. My code is attached.
When I did run it in workspaces it worked. I got the tupples for all the different cases of the string but the checker on the code challenge is giving me an error message: "Bummer! Got the wrong string(s) for: Uppercase, Reversed, Titlecase, Lowercase."
Awaiting your urgent response please.
Thank you.
def stringcases(str):
for char in enumerate(str.upper(), start=1):
return ("{}: {}".format(*char))
for char in enumerate(str.lower(), start=1):
return ("{}: {}".format(*char))
for char in enumerate(str.title(), start=1):
return ("{}: {}".format(*char))
give = str[-1::-1]
for char in enumerate(give, start=1):
return ("{}: {}".format(*char))
1 Answer
Philipp Rรคse
Courses Plus Student 10,298 PointsHello there,
I used this code below and it works as expected. I hope you already found a good solution by yourself.
Otherwise maybe this will help:
def stringcases(string):
string_uppercase = string.upper() #str-Function for uppercase
string_lowercase = string.lower() #str-Function for lowercase
string_titlecase = string.title() #str-Function for first letter of each word capitalized
string_list = list(string) #Make a list from my string to make it 'accessable'
string_reversed = "".join(string_list[-1::-1]) #build a reversed string from my list of characters
return (string_uppercase, string_lowercase, string_titlecase, string_reversed) #return the tuple
Idris Abdulwahab
Courses Plus Student 2,961 PointsIdris Abdulwahab
Courses Plus Student 2,961 PointsI have also tried this:
It also produced a tuple with different string formats but the checker still gives me an error message on the code challenge.
Awaiting hints from someone please.
Thank you.