I am trying to use some for loops to take a sentence and capitalize the first letter of each word.
p1 = "the cat in the hat"
def title_creator(p1):
p = p1.split()
p_len = len(p)
d = []
for i in range(p_len):
first_letter = p[i][0]
m = first_letter.upper()
d.append(m)
p[i][0] == d[i]
p = " ".join(p)
return p
z = title_creator(p1)
print(z)
This outputs the same original sentence from the top. How would I be able to replace an index from one list to another?
-ps I'm sorry if this problem is really easy and I'm just overlooking something simple.