I am currently doing an online beginners course in Python and am stuck with this one element.
I have
listA = ['a','d','g','p','l','g','r','e']
listB = ['a','p','p','l','e']
listC = ['_','_','_','_','_']
I am comparing letters in list a to see if they are in list B, and if true then replace the same index in list C with that letter.The following code is in a function:
for a in listA:
for b in listB:
if a==b:
listC.append(listB.index(b))
stringC = str(listC)
print(stringC)
The problem is that list C gets appended at the correct place, but with the int value of the index.
How can I replace the letter and not the index value?
Many Thanks!