if you want to get every element in the list to be title, you need a for loop
musicTitles = [] # create an empty list we’ll populate it under for str in music: # takes every element in music so str is first “kay”, then “em” and so on musicTitle = str.title() # gets for example Kay musicTitles.append(musicTitle) # adds it to the list which we’ll use
another way to do it is to replace the list itself
i = 0 # this will be our index for str in music: # same thing as above music[i] = str.title() # music[0] = str.title() would replace the first element with the title i += 1 # and i will be first 0 then 1 and so on for every element
2
u/wentaas Aug 02 '20
if you want to get every element in the list to be title, you need a for loop
musicTitles = [] # create an empty list we’ll populate it under for str in music: # takes every element in music so str is first “kay”, then “em” and so on musicTitle = str.title() # gets for example Kay musicTitles.append(musicTitle) # adds it to the list which we’ll use
print(musicTitles)