Omitting values in a list comprehension, instead of using dummy values

My code:

new_list = [
    num * 0.99 if num > 40 else num * 2 if 20 < num > 30 else "delete" 
    for num in range(50)
]
print(new_list)

How can I have both conditions executed and the code will work without including the last condition?

Meaning that all the numbers that get the value “delete” in advance will not add to the new list, just only the numbers that satisfy the first two conditions will be added.

The output will be:

[
    62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 
    40.589999999999996, 41.58, 42.57, 43.56,
    44.55, 45.54, 46.53, 47.519999999999996,
    48.51
]

instead of:

[
    'delete', 'delete', 'delete', 'delete', 'delete',
    'delete', 'delete', 'delete', 'delete', 'delete',
    'delete', 'delete', 'delete', 'delete', 'delete',
    'delete', 'delete', 'delete', 'delete', 'delete',
    'delete', 'delete', 'delete', 'delete', 'delete',
    'delete', 'delete', 'delete', 'delete', 'delete',
    'delete', 62, 64, 66, 68, 70, 72, 74, 76, 78, 80,
    40.589999999999996, 41.58, 42.57, 43.56, 44.55,
    45.54, 46.53, 47.519999999999996, 48.51
]

Answer

If I’ve understood your question correctly, you want to limit the list comprehension by if num > 30:

new_list = [
    num * 0.99 if num > 40 else num * 2 for num in range(50) if num > 30
]
print(new_list)

Prints:

[62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 40.589999999999996, 41.58, 42.57, 43.56, 44.55, 45.54, 46.53, 47.519999999999996, 48.51]