Python Python Collections (2016, retired 2019) Slices sillyCase

kenneth love challenege

Challenge Task 1 of 1 I need you to create a new function for me.

This one will be named sillycase and it'll take a single string as an argument.

sillycase should return the same string but the first half should be lowercased and the second half should be uppercased. For example, with the string \"Treehouse\", sillycase would return \"treeHOUSE\".

Don't worry about rounding your halves, but remember that indexes should be integers. You'll want to use the int() function or integer division, //."

i couldnt solve this! help

sillycase.py
def sillycase(argument):
    return argument

3 Answers

Steven Parker
Steven Parker
177,847 Points

Here's some hints that my help:

  • the integer division mentioned would be useful for finding half of the length
  • a "slice" would be a way to get the first (or last) part of a string
  • there are functions that change the case of a string
  • parts of a string can be (re)joined by concatenation (the "+" operator)

If you're still stuck, you might take a look at some of the answers to previous questions asked about the same exercise.

mersadajan
mersadajan
15,521 Points

First divide the string into two halves. Put each halve in a variable. Put the first string into lower case and the second string into uppercase. Return the concatenated string. I am not sure if this is going to far in regards to "helping"

ERDAL DINCER
ERDAL DINCER
1,474 Points

sillycase=['Treehouse'] len=len(sillycase) sillycase=sillycase.upper(0:(len/2+1)+sillycase.lower(len/2::)

What is wrong with this coding ?

Steven Parker
Steven Parker
177,847 Points

See the comments in this other question where you posted the same thing.
And remember to start a fresh question next time.