mercredi 10 février 2021

how to check two conditions in a single block rather than 2 in python

            if 'hiring ' in job_title:
                job_title = job_title.split("hiring ")[1]
                if job_title.startswith('– '):
                    job_title = job_title.replace('– ', '')
            elif 'Hiring ' in job_title:
                job_title = job_title.split("Hiring ")[1]
                if job_title.startswith('– '):
                    job_title = job_title.replace('– ', '')
            job_titles.append(job_title)

So I have this snippet of code and I want to check if the string variable job_title has either 'hiring' or 'Hiring' in it and then get the text after this word by splitting job_title...I want to do it in a single if statement...but right now I have two...How can I do that because for a single statement:

            if 'hiring ' or 'Hiring ' in job_title:
                job_title = job_title.split("hiring ")[1]
                if job_title.startswith('– '):
                    job_title = job_title.replace('– ', '')

I have to split at either 'hiring' or 'Hiring'... Any ideas?

Aucun commentaire:

Enregistrer un commentaire