I want to remove a special character from a set of string values in Python.
I apply the below-mentioned logic.
I'm getting the exact output I wanted, but can anyone help me with a short and more convenient approach?
job = {'job', 'entrepreneur', 'student', 'services', 'housemaid', 'management', 'self-
employed','admin.', 'blue-collar', 'technician'}
#print(job)
job_copy = set()
val = ''
for j in job:
if j.isalnum():
job_copy.add(j)
else:
for char in j:
if char.isalnum():
val = val+char
job_copy.add(val)
val = ''
print(job_copy)
OUTPUT
{'technician', 'housemaid', 'selfemployed', 'entrepreneur', 'job', 'services', 'admin', 'management', 'student', 'bluecollar'}