Sep-21-2019, 01:18 AM
(Sep-21-2019, 12:57 AM)ichabod801 Wrote: I would use enumerate and then index assignment.
Do you mean doing it this way? It did work if each letter is unique, however when there are two same letters within line 1 it will only detect and replace the first one and igonring the second one.
line1 = 'november' line2 = ['*', '*', '*', '*', '*', '*', '*', '*',] password = input('enter a letter in the password') for i in line1: if i == password: line2[line1.index(i)] = password print(line2)result of running this code:
['*', '*', '*', 'e', '*', '*', '*', '*']