I’m trying to modify the above code to capitalize the first and fourth letters of all words in a list.
def my_function(name_list):
new_list = []
for name in name_list:
if len(name) > 3:
new_list.append(name[:3].capitalize() + name[3:].capitalize())
else:
new_list.append('Name is too short')
return new_list
result = my_function(['oldmac', 'hippo', 'mouse'])
print(result)
Modify the code above to capitalize the first and fourth letters of all words in a list:
def my_function(name_list):
new_list = []
for name in name_list:
if len(name) > 3:
new_list.append(name[:3].capitalize() + name[3:].capitalize())
else:
new_list.append('Name is too short')
return new_list
result = my_function(['oldmac', 'hippo', 'mouse'])
print(result)
Modify the code to capitalize the first and fourth letters of all words in a list:
def my_function(name_list):
new_list = []
for name in name_list:
if len(name) > 3:
new_list.append(name[:3].capitalize() + name[3:].capitalize())
else:
new_list.append('Name is too short')
return new_list
result = my_function(['oldmac', 'hippo', 'mouse'])
print(result)
Modify the code to capitalize the first and fourth letters of all words in a given list:
def my_function(name_list):
new_list = []
for name in name_list:
if len(name) > 3:
new_list.append(name[:3].capitalize() + name[3:].capitalize())
else:
new_list.append('Name is too short')
return new_list
result = my_function(['oldmac', 'hippo', 'mouse'])
print(result)