samedi 16 mai 2015

if/else statements accepting strings in both capital and lower-case letters in python

Is there a quick way for an "if" statement to accept a string regardless of whether it's lower-case, upper-case or both in python?

I'm attempting to write a piece of code where the number "3" can be entered as well as the word "three"or "Three" or any other mixture of capital and lower-case and it will still be accepted will still be accepted by the "if" statement in the code. I know that I can use "or" to get it to accept "3" as well as any other string however don't know how to get it to accept the string in more than one case. So far I have:

if (Class == "3" or Class=="three"):
    f=open("class3.txt", "a+")

Aucun commentaire:

Enregistrer un commentaire