dimanche 1 septembre 2019

Store the if else output in a variable in python

I have want to write and store a simple if else output in a value. I have filenames like this.

US_Sales_2019090200022300023223155

UK_Sales_2019090200022300023223155

Sales_2019090210022300023223155

Sales_2019090210022300023223155

If Country is US or UK , I want to store the output value in Country as US or UK (Country1==file[:2]). If not I want to store the output value in Country as like 201909021 (Country2==file[5:13])

Please help me.

Country==[]
Country1==file[:2]
Country2==file[5:13]

if Country1=='US'|Country1=='UK':
     Country1==Country
else:
     Country2==Country

Aucun commentaire:

Enregistrer un commentaire