jeudi 20 juin 2019

Is there an easier way to Check a Variable Value - if it matches a list of values output a corresponding value

I have list of Values - 45 Rows:

Finance:David Bowie

Security:John Denver

Human Resources:Dennis Hopper

Maintenance:Steve Glover

Information Services:Danny Elfman

I would like to be able to check for a specific value and ignore the case of the letters, and output the matching value.

I am trying to make this efficient as much as possible (fast)

Other than the nest If and elif (45 of them), is there a faster way to do this or a more efficient way?

Need t be able to be CASE INSENSITIVE

If something == "FinANce":
 print ("Assign To=David Bowie")
elif something == 'security':
 print ("Assign To=John Denver")
elif something == 'Human Resources':
 print ("Assign To=Dennis Hopper")
else:
 print ("Assign To=Trent Reznor")

Aucun commentaire:

Enregistrer un commentaire