mercredi 11 juillet 2018

How to make the if statement case insensitive python

Using an if statement as part of a bigger program to compare 2 names, problem is that the first word is all caps while the other is just in title case and while using the .title() works in most cases, sometimes there are words like 'for' and 'on' and 'a' which cause trouble since they get capitalized in the first word but they aren't capitalized in the second by default so the program just skips the entry.

Like for example the name of this journal : CA-A CANCER JOURNAL FOR CLINICIANS , in the first document it's written as "CA-A CANCER JOURNAL FOR CLINICIANS" and after .title() it becomes "Ca-A Cancer Journal For Clinicians" but in the second list which I'm comparing to it's written "Ca-A Cancer Journal for Clinicians" is there a way to make a function like .title() in which I can add exceptions?

Aucun commentaire:

Enregistrer un commentaire