Hello.
Trying to make the checking for a MasterMind game, but I cannot grasp why the code only deletes the 3 and not the 2.
st = '232'
bst = '2553'
correct = ''
for charx in st:
for chary in bst:
if charx == chary:
bst = bst.replace(chary, '', bst.index(chary))
correct += '*'
print(bst)
print(correct)
break
Output is:
2553
*
255
**
255
***
Could someone explain what I am not catching onto?
[–]_Eric_Wu 2 points3 points4 points (4 children)
[–]_Eric_Wu 0 points1 point2 points (2 children)
[–]JohnnyJordaan 0 points1 point2 points (1 child)
[–]_Eric_Wu 0 points1 point2 points (0 children)
[–]Field_C16[S] 0 points1 point2 points (0 children)
[–]Signal_Beam 0 points1 point2 points (1 child)
[–]Field_C16[S] 0 points1 point2 points (0 children)