how to solve Jaden Casing Strings kata 7kyu in Python


Jaden Smith, the son of Will Smith, is the star of films such as The Karate Kid (2010) and After Earth (2013). Jaden is also known for some of his philosophy that he delivers via Twitter. When writing on Twitter, he is known for almost always capitalizing every word. For simplicity, you'll have to capitalize each word, check out how contractions are expected to be in the example below.

Your task is to convert strings to how they would be written by Jaden Smith. The strings are actual quotes from Jaden Smith, but they are not capitalized in the same way he originally typed them.

Example:

Not Jaden-Cased: "How can mirrors be real if our eyes aren't real"
Jaden-Cased:     "How Can Mirrors Be Real If Our Eyes Aren't Real"




solution:

1.  split string to make list e.g new_list = string.split()
2. make another empty list e.g new_list2 =[]
3. iterate through new_list and add first letter capitalised element to new_list2
    e.g for i in new_list: 
                new_list2.append(i)
4. return join of new_list2 e.g return " ".join(new_list2)


def to_jaden_case(string):
    str1 = ""
    string_list = string.split()
    string_list2 = []
    for i in string_list:
        string_list2.append(i.capitalize())
    
    return " ".join(string_list2)

-----------------------------------------------------------
go solve the kata click link




Comments