-1

I'm new to python.

I have a couple of list of dict. I just wanted to create a single list of dict.

List 1:

[{'mnemonic': u'VERS', 'value': '2.0', 'unit': u'', 'description': u'CWLS LOG ASCII STANDARD - VERSION 2.0'}, 
{'mnemonic': u'WRAP', 'value': 'NO', 'unit': u'', 'description': u'ONE LINE PER DEPTH STEP'}]

List 2:

[{'mnemonic': u'STRT', 'value': '3122.0', 'unit': u'FT', 'description': u'START DEPTH'}, 
{'mnemonic': u'STOP', 'value': '4968.0', 'unit': u'FT', 'description': u'STOP DEPTH'}]
Shankar
  • 8,529
  • 26
  • 90
  • 159

1 Answers1

1

What you are trying to do is concatinate two lists, this can be done with the + operator in python, like so:

list1 = [{'mnemonic': u'VERS', 'value': '2.0', 'unit': u'', 'description': u'CWLS LOG ASCII STANDARD - VERSION 2.0'}, {'mnemonic': u'WRAP', 'value': 'NO', 'unit': u'', 'description': u'ONE LINE PER DEPTH STEP'}]
list2 = [{'mnemonic': u'STRT', 'value': '3122.0', 'unit': u'FT', 'description': u'START DEPTH'}, {'mnemonic': u'STOP', 'value': '4968.0', 'unit': u'FT', 'description': u'STOP DEPTH'}]

list3 = list1 + list2
Aaron N. Brock
  • 4,276
  • 2
  • 25
  • 43