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 trialhelmi al kindy
1,371 PointsCan't make it work on my pc
I've already passed this section but when I try to run this code on my computer I get an invalid syntax error.
I use the print command after the function. Eg: print sillycase('hello')
# 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(t):
leng = round(len(t)/2)
return t[:leng].lower() + t[leng:].upper()
2 Answers
Roman Saibullin
5,805 Pointsprint sillycase("hello") #not correct
print(sillycase("hello")) #correct for Python 3.x
helmi al kindy
1,371 PointsNo it doesn't work.
Todd Farr
9,547 PointsI guess I should have first asked what version of Python you are using?
Todd Farr
9,547 PointsTodd Farr
9,547 Pointslen(t) / 2 will already preform integer division leaving you will a whole number. By adding the round(len(t) / 2) you are actually assigning 2.0 to leng and floating points numbers cannot be used for the string slicing operation. Remove round() and your program will work!
Hope this helps!