@Saanvi Sharma, you're doing this in Spark?
You can declare the variable as a list, for exampe - comp_list=['AB01','BC01']
Then you can filter it with rdd.filter(lambda x:not(x in comp_list)), if you're filtering on this string directly,
Otherwise you can put your field as an argument to lambda expression.
Similar concept may be applied if you're doing this any other way.