Basically what the title says, Im trying to delete all names that have numbers in the string, what I was expecting from my code was:
['hello', 'number']
And what I got was:
['hello', 'number', 'Z23', 'Z46', 'U-557', 'U-81']
Here the code I'm using:
allnames1 = ['hello','Z18', 'number','Z20', 'Z23', 'Z28', 'Z46','U-101', 'U-557', 'U-73', 'U-81', 'U-96']
for name in allnames1:
x = re.findall("\d",name)
if len(x) != 0:
allnames1.remove(name)
print(allnames1)
Why doesnt my code work as intended?
How can I modify the code for it to give me my expected output?