I am new to python and can not understand one thing in this code below:
def big_letter(text):
for i in range(len(text)):
text[i]= text[i].title()
names = ['nick', 'john', 'hugh', 'tony']
big_letter(names)
print(names)
WHAT IS THE "LEN" AND "RANGE" FUNCTIONS DOING HERE ACTUALLY?
I tried to manage things by deleting them in this code. They have some cost here but can not understand what exactly they did.
>Solution :
So, I believe this code is trying to convert all the contents of the names list to title case. Explanation of code:
def big_letter(text):
for i in range(len(text)):# start a loop that runs for the length of list text
# basically trying to cycle through the elements of
# the list one by one
text[i]= text[i].title() # converting each element to title case and
# assigning them to the list
# print(text) # I have added this. uncomment to see the process
names = ['nick', 'john', 'hugh', 'tony']
big_letter(names) # Calling the function while passing the parameter
print(names) # printing the list