Question: I have a list of tuples, and I want to remove a tuple if the the first element in the tuple does not have a number within it. Below is the code I currently have.

```
x = [('akj_vx', 1.2559392760527808, 1.0), ('39Sbw£', 1.5930205922, 2.0), ('bg1HEw*', 1.95830294, 1.0)]

for item in x:
  print("Time", item[1],": ID", item[0], "Exponent", item[2],)
  if re.search(r"\d", item[0]):
    print("Task", item[0] ,"Accepted \n")
  else:
    print("Task", item[0], "discarded \n")

print(x)

```

When I print my list (x), I want the output to be:

```
[('39Sbw£', 1.5930205922, 2.0), ('bg1HEw*', 1.95830294, 1.0)]

```

What can I add to my code to ensure this?

Answer: 
You can use a list comprehension to create a list satisfying the criterion instead of removing the unnecessary items:

```
x = [item for item in x if re.search(r"\d", item[0])]

```

Alternatively, you can use pure Python as well (without any module dependency):

```
x = [item for item in x if any(y.isdigit() for y in item[0])]

```

---

As requested in comments, you could also remove by index (not recommended):

```
for i, item in enumerate(x):
    if not any(y.isdigit() for y in item[0]):
        del x[i]

```
If you don't want to use `re` module, you can use this:

```
x = [('akj_vx', 1.2559392760527808, 1.0), ('39Sbw£', 1.5930205922, 2.0), ('bg1HEw*', 1.95830294, 1.0)]

x = [i for i in x if any(ch in '0123456789' for ch in i[0])]
print(x)

```

Prints:

```
[('39Sbw£', 1.5930205922, 2.0), ('bg1HEw*', 1.95830294, 1.0)]

```

EDIT (or use `.isdigit()`):

```
x = [i for i in x if any(ch.isdigit() for ch in i[0])]

```