0

I need to copy fields from one dictionary to another. I'm seeing strange behavior where dictionary['key'] = ... sometimes gives me a Tuple rather than a String which I can't figure out.

Originally, I have a dictionary called agreement which has a String alternate_address field:

enter image description here

Then

formValues = {}
# ...
formValues['street'] = agreement.get('alternate_address', None),

gives me the following. Note that a similar field, city, also containing spaces, has no issues and remains a String, and I fetch it in exactly the same way.

enter image description here

gene b.
  • 10,512
  • 21
  • 115
  • 227
  • 2
    `formValues['street'] = agreement.get('alternate_address', None),` - note the comma at the end. Your dictionary has a tuple because you put a tuple into it. – kaya3 May 29 '21 at 17:00
  • 1
    The trailing comma in `None),` makes the right-hand side a tuple. – Carcigenicate May 29 '21 at 17:00

0 Answers0