mardi 30 avril 2019

How to fetch values from if else condition?

I am trying to get a code using if else condition.I wish to take values from if else condition .

Currently if condition works, not working for else condition.

mname=input("Enter  name: ")
    m=[]

        if mname=="CS1TFD22" or "cs1tfd22":
            mcode='CS122S003'
            if l1l2=="NULL":
                icode = 'CS122S003d13_mh_'
            elif l1l2!="NULL":
                icode = 'CS122S003d13_L1_mh_'

        else:
            for i in mname:
                m.append(i)

            mcode = 'CS1'+m[5]+m[6]+'S003'
            if l1l2=="NULL":
                icode='CS1'+m[5]+m[6]+'S003d113_mh_'
            elif l1l2 != "NULL":
                icode = CS1'+m[5]+m[6]+'S003d13_L1_mh_'

        print(mcode,icode)

Output I get is always mcode='CS122S003' and icode='CS122S003d13_L1_mh_', if mname is not 'CS1TFD22'. For example if I enter mname as CS1TFD23 , then icode should be 'CS123S003' and icode should be 'CS123S003d13_mh'

How to work for else condition also?

Aucun commentaire:

Enregistrer un commentaire