I have a python dictionary like so:
{
"addressLineOne": self.ADDRESS_1,
"addressType": "RESIDENTIAL",
"city": self.CITY,
"countryCode": "USA",
"email": self.EMAIL,
"firstName": self.FIRST_NAME,
"state": self.STATE
}
I want some values to be condition the way I'm currently doing it is like so:
if self.login:
data = {"addressLineOne": self.ADDRESS_1,
"addressType": "RESIDENTIAL",
"city": self.CITY,
"countryCode": "USA",
"state": self.STATE}
else:
data = {"addressLineOne": self.ADDRESS_1,
"addressType": "RESIDENTIAL",
"city": self.CITY,
"countryCode": "USA",
"email": self.EMAIL,
"firstName": self.FIRST_NAME,
"state": self.STATE}
Is there a neater/tidier way of doing this so I don't need to write the dictionary twice, for example including an if/else statement within the dictionary?