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!

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) Slices sillyCase

My program throws up an error "builtin_function" has no attribute my_string , No matter what name i give to attribute!!!

My code is def sillycase(my_string): return (my_string[:round((len.my_string)/2)].lower() + my_string[-1:((len.my_string)/2):-1].upper()) whats the error?!?! it always says there's no such argument!!

# The first half of the string, rounded with round(), should be lowercased.
# The second half should be uppercased.
# E.g. "Treehouse" should come back as "treeHOUSE"
def sillycase(my_string):
    return (my_string[:round((len.my_string)/2)].lower() + my_string[-1:((len.my_string)/2):-1].upper())

2 Answers

Christopher Shaw
.a{fill-rule:evenodd;}techdegree seal-36
Christopher Shaw
Python Web Development Techdegree Graduate 58,248 Points

Your first error is that you are using len wrong. It should be len(my_string).

Then the lower part of your answer is then correct. The upper part still has some errors, for a start, you are revering the slice. You can get the start point from the length of my_string - length of the first part.

Hint: You can use the console on the workspace to try out solutions. The errors displayed here can be more helpful in solving the problem.

Charles Williams
Charles Williams
2,680 Points

As the other user pointed out, your main problem is using len.string rather than len(string).

But if this is Python 3 (I think it is), you can do:

my_string[:len(my_string)//2].lower() + my_string[len(my_string)//2:].upper()

Because // does integer division (or just / in Python 2), so there's no need to round. No need to add or subtract from len(). Works well on my end: