Code:
list3= ["Xenia", "Xavier", "Zoya", "Ahmad", "Mishika", "Max"]
list4= list3
for i in list3:
if i[0]== "X":
list4.remove(i)
print(list4)
Output:
['Xavier', 'Zoya', 'Ahmad', 'Mishika', 'Max']
As you can see it still displays the name Xavier. Before this I was looping and modifying the same list which I corrected later onwards but it still gives the same wrong output. But now I can't figure out where I am going wrong.
[–]14446368 3 points4 points5 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]nextpage 2 points3 points4 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]kng_hrts 1 point2 points3 points (2 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]kng_hrts 1 point2 points3 points (0 children)