Repository: Qiskit/qiskit

Issue:
marginal_counts cannot marginalize over previously Result object in main branch
### Environment

- **Qiskit Terra version**: main
- **Python version**: 3.9
- **Operating system**:  OSX


### What is happening?

The `marginal_counts` function is failing with error `ValueError: invalid literal for int() with base 2: ''`

### How can we reproduce the issue?

Execute
<details><summary>Expand for long command...</summary>

```python
from qiskit.result import Result, marginal_counts

result_dict = {'backend_name': 'ibm_wellington',
 'backend_version': '1.0.26',
 'qobj_id': 'Unknown',
 'job_id': 'qasm3-runner_c9tg64b9rr0udeiu3cm0_7d50_0',
 'success': True,
 'results': [{'shots': 1000,
   'success': True,
   'data': {'counts': {'0x0': 237,
     '0x1': 232,
     '0x2': 179,
     '0x3': 151,
     '0x4': 58,
     '0x5': 50,
     '0x6': 46,
     '0x7': 47},
    'memory': ['0x1',
     '0x0',
     '0x4',
     '0x7',
     '0x2',
     '0x3',
     '0x1',
     '0x0',
     '0x3',
     '0x4',
     '0x0',
     '0x3',
     '0x2',
     '0x0',
     '0x0',
     '0x1',
     '0x0',
     '0x3',
     '0x2',
     '0x5',
     '0x0',
     '0x3',
     '0x1',
     '0x1',
     '0x2',
     '0x1',
     '0x1',
     '0x1',
     '0x0',
     '0x2',
     '0x0',
     '0x7',
     '0x5',
     '0x4',
     '0x5',
     '0x1',
     '0x2',
     '0x0',
     '0x1',
     '0x4',
     '0x0',
     '0x2',
     '0x4',
     '0x3',
     '0x2',
     '0x3',
     '0x3',
     '0x4',
     '0x4',
     '0x3',
     '0x1',
     '0x2',
     '0x2',
     '0x0',
     '0x2',
     '0x2',
     '0x4',
     '0x0',
     '0x5',
     '0x3',
     '0x3',
     '0x4',
     '0x2',
     '0x4',
     '0x3',
     '0x2',
     '0x2',
     '0x6',
     '0x0',
     '0x3',
     '0x2',
     '0x2',
     '0x2',
     '0x2',
     '0x1',
     '0x2',
     '0x3',
     '0x3',
     '0x4',
     '0x1',
     '0x0',
     '0x0',
     '0x3',
     '0x7',
     '0x2',
     '0x2',
     '0x1',
     '0x1',
     '0x2',
     '0x1',
     '0x0',
     '0x2',
     '0x4',
     '0x1',
     '0x0',
     '0x0',
     '0x2',
     '0x0',
     '0x0',
     '0x3',
     '0x0',
     '0x2',
     '0x3',
     '0x3',
     '0x6',
     '0x1',
     '0x7',
     '0x1',
     '0x3',
     '0x1',
     '0x0',
     '0x0',
     '0x0',
     '0x3',
     '0x1',
     '0x2',
     '0x1',
     '0x2',
     '0x4',
     '0x3',
     '0x1',
     '0x0',
     '0x1',
     '0x3',
     '0x2',
     '0x1',
     '0x6',
     '0x3',
     '0x6',
     '0x1',
     '0x0',
     '0x0',
     '0x7',
     '0x0',
     '0x1',
     '0x5',
     '0x0',
     '0x0',
     '0x3',
     '0x0',
     '0x0',
     '0x0',
     '0x3',
     '0x3',
     '0x2',
     '0x2',
     '0x1',
     '0x4',
     '0x2',
     '0x3',
     '0x2',
     '0x1',
     '0x6',
     '0x5',
     '0x5',
     '0x0',
     '0x2',
     '0x4',
     '0x4',
     '0x3',
     '0x7',
     '0x2',
     '0x5',
     '0x1',
     '0x3',
     '0x0',
     '0x2',
     '0x4',
     '0x0',
     '0x1',
     '0x5',
     '0x3',
     '0x2',
     '0x4',
     '0x1',
     '0x1',
     '0x6',
     '0x0',
     '0x0',
     '0x3',
     '0x0',
     '0x3',
     '0x5',
     '0x1',
     '0x3',
     '0x5',
     '0x2',
     '0x2',
     '0x3',
     '0x3',
     '0x0',
     '0x0',
     '0x1',
     '0x0',
     '0x7',
     '0x1',
     '0x0',
     '0x0',
     '0x3',
     '0x0',
     '0x0',
     '0x0',
     '0x2',
     '0x1',
     '0x0',
     '0x0',
     '0x5',
     '0x7',
     '0x2',
     '0x1',
     '0x3',
     '0x0',
     '0x2',
     '0x1',
     '0x4',
     '0x0',
     '0x6',
     '0x3',
     '0x1',
     '0x2',
     '0x0',
     '0x5',
     '0x3',
     '0x4',
     '0x5',
     '0x1',
     '0x1',
     '0x3',
     '0x1',
     '0x5',
     '0x2',
     '0x2',
     '0x1',
     '0x2',
     '0x3',
     '0x2',
     '0x1',
     '0x4',
     '0x0',
     '0x0',
     '0x1',
     '0x6',
     '0x3',
     '0x7',
     '0x1',
     '0x7',
     '0x0',
     '0x0',
     '0x0',
     '0x0',
     '0x1',
     '0x5',
     '0x0',
     '0x2',
     '0x1',
     '0x1',
     '0x3',
     '0x5',
     '0x0',
     '0x3',
     '0x0',
     '0x5',
     '0x3',
     '0x1',
     '0x0',
     '0x2',
     '0x1',
     '0x1',
     '0x4',
     '0x2',
     '0x1',
     '0x2',
     '0x1',
     '0x2',
     '0x0',
     '0x0',
     '0x2',
     '0x1',
     '0x4',
     '0x0',
     '0x2',
     '0x7',
     '0x2',
     '0x0',
     '0x0',
     '0x1',
     '0x1',
     '0x2',
     '0x0',
     '0x0',
     '0x1',
     '0x1',
     '0x7',
     '0x1',
     '0x1',
     '0x1',
     '0x0',
     '0x2',
     '0x6',
     '0x1',
     '0x3',
     '0x0',
     '0x0',
     '0x6',
     '0x3',
     '0x3',
     '0x5',
     '0x1',
     '0x3',
     '0x0',
     '0x0',
     '0x1',
     '0x5',
     '0x3',
     '0x2',
     '0x1',
     '0x2',
     '0x7',
     '0x7',
     '0x0',
     '0x7',
     '0x1',
     '0x2',
     '0x7',
     '0x1',
     '0x0',
     '0x1',
     '0x0',
     '0x2',
     '0x1',
     '0x0',
     '0x6',
     '0x0',
     '0x3',
     '0x0',
     '0x1',
     '0x1',
     '0x0',
     '0x0',
     '0x2',
     '0x0',
     '0x1',
     '0x2',
     '0x2',
     '0x1',
     '0x1',
     '0x6',
     '0x6',
     '0x7',
     '0x0',
     '0x1',
     '0x1',
     '0x1',
     '0x2',
     '0x1',
     '0x0',
     '0x0',
     '0x2',
     '0x3',
     '0x0',
     '0x0',
     '0x1',
     '0x2',
     '0x3',
     '0x1',
     '0x7',
     '0x1',
     '0x4',
     '0x1',
     '0x0',
     '0x2',
     '0x0',
     '0x6',
     '0x4',
     '0x5',
     '0x1',
     '0x1',
     '0x4',
     '0x2',
     '0x0',
     '0x7',
     '0x7',
     '0x2',
     '0x1',
     '0x6',
     '0x7',
     '0x2',
     '0x1',
     '0x0',
     '0x3',
     '0x0',
     '0x1',
     '0x2',
     '0x4',
     '0x0',
     '0x0',
     '0x0',
     '0x3',
     '0x0',
     '0x1',
     '0x2',
     '0x4',
     '0x6',
     '0x2',
     '0x2',
     '0x0',
     '0x2',
     '0x1',
     '0x4',
     '0x2',
     '0x1',
     '0x3',
     '0x1',
     '0x0',
     '0x7',
     '0x5',
     '0x0',
     '0x0',
     '0x4',
     '0x0',
     '0x3',
     '0x3',
     '0x0',
     '0x1',
     '0x0',
     '0x0',
     '0x0',
     '0x3',
     '0x3',
     '0x6',
     '0x2',
     '0x3',
     '0x1',
     '0x3',
     '0x6',
     '0x1',
     '0x3',
     '0x1',
     '0x7',
     '0x2',
     '0x5',
     '0x7',
     '0x0',
     '0x6',
     '0x6',
     '0x3',
     '0x0',
     '0x3',
     '0x1',
     '0x7',
     '0x0',
     '0x6',
     '0x1',
     '0x7',
     '0x0',
     '0x2',
     '0x2',
     '0x2',
     '0x0',
     '0x5',
     '0x3',
     '0x3',
     '0x1',
     '0x1',
     '0x0',
     '0x4',
     '0x2',
     '0x2',
     '0x3',
     '0x4',
     '0x1',
     '0x0',
     '0x3',
     '0x4',
     '0x0',
     '0x1',
     '0x2',
     '0x0',
     '0x5',
     '0x4',
     '0x0',
     '0x6',
     '0x0',
     '0x6',
     '0x0',
     '0x2',
     '0x1',
     '0x1',
     '0x6',
     '0x1',
     '0x1',
     '0x7',
     '0x7',
     '0x6',
     '0x3',
     '0x0',
     '0x2',
     '0x0',
     '0x2',
     '0x3',
     '0x7',
     '0x2',
     '0x3',
     '0x1',
     '0x2',
     '0x0',
     '0x3',
     '0x2',
     '0x3',
     '0x4',
     '0x3',
     '0x6',
     '0x2',
     '0x2',
     '0x1',
     '0x3',
     '0x2',
     '0x0',
     '0x3',
     '0x3',
     '0x2',
     '0x6',
     '0x1',
     '0x0',
     '0x2',
     '0x2',
     '0x4',
     '0x1',
     '0x3',
     '0x5',
     '0x2',
     '0x0',
     '0x2',
     '0x2',
     '0x3',
     '0x0',
     '0x0',
     '0x0',
     '0x3',
     '0x0',
     '0x7',
     '0x1',
     '0x1',
     '0x2',
     '0x5',
     '0x1',
     '0x1',
     '0x2',
     '0x2',
     '0x3',
     '0x6',
     '0x5',
     '0x0',
     '0x4',
     '0x3',
     '0x3',
     '0x0',
     '0x2',
     '0x3',
     '0x1',
     '0x1',
     '0x1',
     '0x0',
     '0x1',
     '0x0',
     '0x0',
     '0x2',
     '0x2',
     '0x0',
     '0x1',
     '0x3',
     '0x7',
     '0x1',
     '0x2',
     '0x0',
     '0x3',
     '0x0',
     '0x0',
     '0x1',
     '0x3',
     '0x3',
     '0x7',
     '0x2',
     '0x3',
     '0x2',
     '0x1',
     '0x1',
     '0x0',
     '0x1',
     '0x0',
     '0x0',
     '0x7',
     '0x2',
     '0x5',
     '0x2',
     '0x7',
     '0x2',
     '0x6',
     '0x1',
     '0x5',
     '0x3',
     '0x2',
     '0x2',
     '0x1',
     '0x3',
     '0x1',
     '0x1',
     '0x2',
     '0x7',
     '0x3',
     '0x1',
     '0x2',
     '0x3',
     '0x3',
     '0x0',
     '0x4',
     '0x3',
     '0x0',
     '0x2',
     '0x1',
     '0x1',
     '0x0',
     '0x3',
     '0x0',
     '0x0',
     '0x2',
     '0x1',
     '0x2',
     '0x2',
     '0x1',
     '0x6',
     '0x5',
     '0x3',
     '0x2',
     '0x6',
     '0x5',
     '0x2',
     '0x7',
     '0x6',
     '0x2',
     '0x5',
     '0x0',
     '0x1',
     '0x1',
     '0x6',
     '0x2',
     '0x2',
     '0x0',
     '0x0',
     '0x0',
     '0x2',
     '0x3',
     '0x0',
     '0x1',
     '0x1',
     '0x3',
     '0x0',
     '0x0',
     '0x3',
     '0x4',
     '0x2',
     '0x0',
     '0x0',
     '0x3',
     '0x3',
     '0x2',
     '0x1',
     '0x6',
     '0x5',
     '0x4',
     '0x3',
     '0x0',
     '0x0',
     '0x2',
     '0x6',
     '0x1',
     '0x0',
     '0x0',
     '0x2',
     '0x0',
     '0x0',
     '0x3',
     '0x1',
     '0x0',
     '0x1',
     '0x1',
     '0x1',
     '0x1',
     '0x1',
     '0x1',
     '0x1',
     '0x3',
     '0x1',
     '0x4',
     '0x1',
     '0x1',
     '0x1',
     '0x5',
     '0x3',
     '0x3',
     '0x2',
     '0x2',
     '0x4',
     '0x6',
     '0x1',
     '0x0',
     '0x3',
     '0x0',
     '0x5',
     '0x3',
     '0x0',
     '0x1',
     '0x3',
     '0x1',
     '0x0',
     '0x1',
     '0x2',
     '0x1',
     '0x0',
     '0x1',
     '0x0',
     '0x2',
     '0x4',
     '0x1',
     '0x0',
     '0x1',
     '0x1',
     '0x2',
     '0x5',
     '0x1',
     '0x5',
     '0x5',
     '0x1',
     '0x3',
     '0x1',
     '0x2',
     '0x1',
     '0x7',
     '0x1',
     '0x0',
     '0x2',
     '0x7',
     '0x2',
     '0x1',
     '0x2',
     '0x0',
     '0x2',
     '0x1',
     '0x1',
     '0x1',
     '0x3',
     '0x0',
     '0x1',
     '0x2',
     '0x5',
     '0x3',
     '0x2',
     '0x1',
     '0x0',
     '0x0',
     '0x5',
     '0x2',
     '0x1',
     '0x0',
     '0x1',
     '0x7',
     '0x0',
     '0x0',
     '0x0',
     '0x2',
     '0x3',
     '0x0',
     '0x0',
     '0x0',
     '0x1',
     '0x3',
     '0x1',
     '0x2',
     '0x4',
     '0x1',
     '0x0',
     '0x1',
     '0x7',
     '0x3',
     '0x3',
     '0x0',
     '0x3',
     '0x1',
     '0x2',
     '0x2',
     '0x6',
     '0x2',
     '0x6',
     '0x0',
     '0x1',
     '0x1',
     '0x2',
     '0x0',
     '0x3',
     '0x3',
     '0x0',
     '0x3',
     '0x0',
     '0x2',
     '0x0',
     '0x1',
     '0x0',
     '0x2',
     '0x0',
     '0x0',
     '0x1',
     '0x6',
     '0x1',
     '0x5',
     '0x0',
     '0x2',
     '0x0',
     '0x2',
     '0x1',
     '0x0',
     '0x1',
     '0x1',
     '0x0',
     '0x0',
     '0x3',
     '0x1',
     '0x2',
     '0x1',
     '0x4',
     '0x1',
     '0x1',
     '0x1',
     '0x1',
     '0x1',
     '0x1',
     '0x0',
     '0x0',
     '0x3',
     '0x4',
     '0x2',
     '0x2',
     '0x3',
     '0x2',
     '0x0',
     '0x0',
     '0x1',
     '0x3',
     '0x2',
     '0x0',
     '0x1',
     '0x3',
     '0x7',
     '0x2',
     '0x3',
     '0x2',
     '0x2',
     '0x0',
     '0x2',
     '0x0',
     '0x0',
     '0x1',
     '0x6',
     '0x1',
     '0x4',
     '0x0',
     '0x3',
     '0x1',
     '0x6',
     '0x5',
     '0x2',
     '0x6',
     '0x4',
     '0x1',
     '0x4',
     '0x3',
     '0x0',
     '0x5',
     '0x2',
     '0x0',
     '0x1',
     '0x2',
     '0x7',
     '0x1',
     '0x3',
     '0x0',
     '0x1',
     '0x1',
     '0x3',
     '0x1',
     '0x4',
     '0x1',
     '0x2',
     '0x4',
     '0x0',
     '0x2',
     '0x1',
     '0x0',
     '0x0',
     '0x2',
     '0x0',
     '0x0',
     '0x4',
     '0x1',
     '0x3',
     '0x0',
     '0x4',
     '0x3',
     '0x6',
     '0x7',
     '0x3',
     '0x2',
     '0x1',
     '0x1',
     '0x1',
     '0x7',
     '0x3',
     '0x7',
     '0x1',
     '0x0',
     '0x1',
     '0x0',
     '0x1',
     '0x5',
     '0x4',
     '0x3',
     '0x2',
     '0x1',
     '0x1',
     '0x7',
     '0x1',
     '0x1',
     '0x4',
     '0x3',
     '0x7',
     '0x0',
     '0x1',
     '0x4',
     '0x1',
     '0x1',
     '0x5',
     '0x6',
     '0x3',
     '0x0',
     '0x0',
     '0x0',
     '0x0',
     '0x1',
     '0x3',
     '0x2',
     '0x0',
     '0x2',
     '0x5',
     '0x1',
     '0x5',
     '0x0',
     '0x6',
     '0x0',
     '0x1',
     '0x1',
     '0x0',
     '0x0',
     '0x0',
     '0x2',
     '0x4',
     '0x6',
     '0x0',
     '0x0',
     '0x1',
     '0x3',
     '0x3',
     '0x3',
     '0x3',
     '0x1',
     '0x0',
     '0x3',
     '0x1',
     '0x0',
     '0x2',
     '0x0',
     '0x1',
     '0x0',
     '0x5',
     '0x3',
     '0x3',
     '0x2',
     '0x2',
     '0x3',
     '0x0',
     '0x0',
     '0x5',
     '0x3',
     '0x2',
     '0x0',
     '0x3',
     '0x1',
     '0x4',
     '0x2',
     '0x0',
     '0x1',
     '0x2']},
   'meas_level': 2,
   'header': {'qubit_labels': [['q', 0],
     ['q', 1],
     ['q', 2],
     ['q', 3],
     ['q', 4],
     ['q', 5],
     ['q', 6]],
    'n_qubits': 7,
    'qreg_sizes': [['q', 7]],
    'clbit_labels': [['c1', 0], ['crz', 0], ['crx', 0]],
    'memory_slots': 3,
    'creg_sizes': [['c1', 1], ['crz', 1], ['crx', 1]],
    'name': "('X',)",
    'global_phase': 4.71238898038469,
    'metadata': {}}},
  {'shots': 1000,
   'success': True,
   'data': {'counts': {'0x0': 135,
     '0x1': 134,
     '0x2': 104,
     '0x3': 105,
     '0x4': 135,
     '0x5': 178,
     '0x6': 101,
     '0x7': 108},
    'memory': ['0x5',
     '0x2',
     '0x7',
     '0x2',
     '0x3',
     '0x7',
     '0x4',
     '0x1',
     '0x4',
     '0x4',
     '0x5',
     '0x5',
     '0x3',
     '0x5',
     '0x4',
     '0x4',
     '0x1',
     '0x7',
     '0x4',
     '0x1',
     '0x7',
     '0x3',
     '0x5',
     '0x5',
     '0x2',
     '0x0',
     '0x2',
     '0x0',
     '0x1',
     '0x3',
     '0x4',
     '0x4',
     '0x1',
     '0x6',
     '0x1',
     '0x5',
     '0x7',
     '0x4',
     '0x3',
     '0x6',
     '0x5',
     '0x5',
     '0x6',
     '0x0',
     '0x0',
     '0x7',
     '0x7',
     '0x6',
     '0x5',
     '0x1',
     '0x3',
     '0x3',
     '0x6',
     '0x5',
     '0x5',
     '0x7',
     '0x0',
     '0x4',
     '0x5',
     '0x5',
     '0x7',
     '0x4',
     '0x6',
     '0x7',
     '0x0',
     '0x5',
     '0x4',
     '0x2',
     '0x4',
     '0x5',
     '0x7',
     '0x1',
     '0x4',
     '0x1',
     '0x4',
     '0x5',
     '0x1',
     '0x6',
     '0x1',
     '0x7',
     '0x5',
     '0x6',
     '0x3',
     '0x4',
     '0x3',
     '0x4',
     '0x4',
     '0x7',
     '0x0',
     '0x4',
     '0x0',
     '0x3',
     '0x5',
     '0x4',
     '0x5',
     '0x0',
     '0x3',
     '0x3',
     '0x4',
     '0x6',
     '0x6',
     '0x5',
     '0x2',
     '0x2',
     '0x7',
     '0x5',
     '0x2',
     '0x0',
     '0x0',
     '0x1',
     '0x6',
     '0x1',
     '0x0',
     '0x0',
     '0x6',
     '0x0',
     '0x2',
     '0x2',
     '0x2',
     '0x6',
     '0x0',
     '0x4',
     '0x0',
     '0x7',
     '0x5',
     '0x0',
     '0x2',
     '0x5',
     '0x3',
     '0x6',
     '0x5',
     '0x4',
     '0x0',
     '0x4',
     '0x4',
     '0x6',
     '0x3',
     '0x0',
     '0x4',
     '0x0',
     '0x1',
     '0x3',
     '0x6',
     '0x0',
     '0x0',
     '0x7',
     '0x7',
     '0x3',
     '0x3',
     '0x2',
     '0x5',
     '0x6',
     '0x1',
     '0x1',
     '0x3',
     '0x2',
     '0x2',
     '0x6',
     '0x5',
     '0x6',
     '0x5',
     '0x1',
     '0x4',
     '0x4',
     '0x5',
     '0x4',
     '0x3',
     '0x2',
     '0x7',
     '0x6',
     '0x4',
     '0x7',
     '0x0',
     '0x0',
     '0x0',
     '0x7',
     '0x4',
     '0x1',
     '0x6',
     '0x5',
     '0x2',
     '0x6',
     '0x3',
     '0x4',
     '0x4',
     '0x5',
     '0x6',
     '0x5',
     '0x7',
     '0x3',
     '0x3',
     '0x5',
     '0x7',
     '0x4',
     '0x5',
     '0x4',
     '0x5',
     '0x0',
     '0x1',
     '0x0',
     '0x1',
     '0x1',
     '0x0',
     '0x6',
     '0x2',
     '0x0',
     '0x5',
     '0x2',
     '0x1',
     '0x1',
     '0x5',
     '0x5',
     '0x0',
     '0x3',
     '0x4',
     '0x2',
     '0x4',
     '0x2',
     '0x0',
     '0x5',
     '0x7',
     '0x6',
     '0x3',
     '0x4',
     '0x5',
     '0x4',
     '0x4',
     '0x0',
     '0x1',
     '0x4',
     '0x5',
     '0x5',
     '0x2',
     '0x2',
     '0x5',
     '0x5',
     '0x1',
     '0x6',
     '0x6',
     '0x1',
     '0x3',
     '0x7',
     '0x2',
     '0x5',
     '0x0',
     '0x7',
     '0x1',
     '0x1',
     '0x5',
     '0x0',
     '0x5',
     '0x5',
     '0x3',
     '0x2',
     '0x0',
     '0x0',
     '0x5',
     '0x3',
     '0x1',
     '0x2',
     '0x0',
     '0x4',
     '0x5',
     '0x5',
     '0x3',
     '0x5',
     '0x3',
     '0x6',
     '0x2',
     '0x1',
     '0x5',
     '0x2',
     '0x7',
     '0x0',
     '0x5',
     '0x6',
     '0x6',
     '0x1',
     '0x7',
     '0x1',
     '0x6',
     '0x6',
     '0x0',
     '0x6',
     '0x6',
     '0x1',
     '0x1',
     '0x7',
     '0x7',
     '0x7',
     '0x2',
     '0x2',
     '0x1',
     '0x0',
     '0x4',
     '0x7',
     '0x4',
     '0x0',
     '0x0',
     '0x6',
     '0x0',
     '0x4',
     '0x4',
     '0x7',
     '0x4',
     '0x7',
     '0x6',
     '0x5',
     '0x1',
     '0x0',
     '0x7',
     '0x4',
     '0x5',
     '0x5',
     '0x5',
     '0x5',
     '0x3',
     '0x5',
     '0x5',
     '0x3',
     '0x0',
     '0x3',
     '0x5',
     '0x0',
     '0x4',
     '0x5',
     '0x6',
     '0x4',
     '0x2',
     '0x3',
     '0x1',
     '0x3',
     '0x5',
     '0x7',
     '0x4',
     '0x6',
     '0x1',
     '0x7',
     '0x5',
     '0x1',
     '0x0',
     '0x5',
     '0x0',
     '0x3',
     '0x3',
     '0x2',
     '0x5',
     '0x5',
     '0x5',
     '0x7',
     '0x2',
     '0x2',
     '0x7',
     '0x3',
     '0x1',
     '0x6',
     '0x1',
     '0x5',
     '0x7',
     '0x1',
     '0x0',
     '0x1',
     '0x5',
     '0x6',
     '0x4',
     '0x6',
     '0x2',
     '0x1',
     '0x7',
     '0x1',
     '0x4',
     '0x5',
     '0x2',
     '0x4',
     '0x0',
     '0x5',
     '0x3',
     '0x5',
     '0x3',
     '0x3',
     '0x3',
     '0x1',
     '0x0',
     '0x5',
     '0x1',
     '0x2',
     '0x2',
     '0x6',
     '0x4',
     '0x2',
     '0x5',
     '0x1',
     '0x3',
     '0x1',
     '0x0',
     '0x2',
     '0x4',
     '0x5',
     '0x1',
     '0x1',
     '0x4',
     '0x5',
     '0x6',
     '0x0',
     '0x1',
     '0x3',
     '0x5',
     '0x5',
     '0x3',
     '0x4',
     '0x4',
     '0x6',
     '0x1',
     '0x5',
     '0x7',
     '0x4',
     '0x7',
     '0x0',
     '0x1',
     '0x6',
     '0x0',
     '0x2',
     '0x6',
     '0x2',
     '0x4',
     '0x1',
     '0x1',
     '0x3',
     '0x7',
     '0x4',
     '0x2',
     '0x7',
     '0x5',
     '0x0',
     '0x4',
     '0x7',
     '0x7',
     '0x2',
     '0x0',
     '0x7',
     '0x5',
     '0x6',
     '0x0',
     '0x4',
     '0x2',
     '0x2',
     '0x0',
     '0x5',
     '0x1',
     '0x2',
     '0x5',
     '0x3',
     '0x7',
     '0x5',
     '0x5',
     '0x2',
     '0x2',
     '0x4',
     '0x0',
     '0x4',
     '0x1',
     '0x5',
     '0x4',
     '0x5',
     '0x2',
     '0x5',
     '0x3',
     '0x5',
     '0x7',
     '0x5',
     '0x4',
     '0x3',
     '0x4',
     '0x2',
     '0x3',
     '0x2',
     '0x0',
     '0x5',
     '0x1',
     '0x6',
     '0x0',
     '0x2',
     '0x7',
     '0x5',
     '0x4',
     '0x5',
     '0x6',
     '0x0',
     '0x4',
     '0x1',
     '0x2',
     '0x0',
     '0x2',
     '0x5',
     '0x0',
     '0x2',
     '0x5',
     '0x4',
     '0x7',
     '0x4',
     '0x5',
     '0x3',
     '0x5',
     '0x5',
     '0x6',
     '0x1',
     '0x3',
     '0x7',
     '0x0',
     '0x3',
     '0x5',
     '0x2',
     '0x2',
     '0x5',
     '0x4',
     '0x1',
     '0x7',
     '0x4',
     '0x3',
     '0x7',
     '0x6',
     '0x1',
     '0x5',
     '0x0',
     '0x0',
     '0x5',
     '0x5',
     '0x1',
     '0x6',
     '0x0',
     '0x3',
     '0x0',
     '0x5',
     '0x0',
     '0x7',
     '0x0',
     '0x6',
     '0x1',
     '0x7',
     '0x0',
     '0x6',
     '0x6',
     '0x0',
     '0x1',
     '0x3',
     '0x4',
     '0x6',
     '0x1',
     '0x6',
     '0x7',
     '0x0',
     '0x0',
     '0x1',
     '0x4',
     '0x6',
     '0x0',
     '0x7',
     '0x6',
     '0x7',
     '0x0',
     '0x0',
     '0x5',
     '0x0',
     '0x2',
     '0x2',
     '0x7',
     '0x4',
     '0x4',
     '0x3',
     '0x0',
     '0x5',
     '0x6',
     '0x5',
     '0x1',
     '0x7',
     '0x5',
     '0x7',
     '0x5',
     '0x4',
     '0x5',
     '0x0',
     '0x7',
     '0x7',
     '0x0',
     '0x0',
     '0x1',
     '0x5',
     '0x5',
     '0x2',
     '0x2',
     '0x1',
     '0x5',
     '0x4',
     '0x3',
     '0x7',
     '0x3',
     '0x6',
     '0x0',
     '0x1',
     '0x1',
     '0x2',
     '0x2',
     '0x3',
     '0x2',
     '0x6',
     '0x0',
     '0x0',
     '0x3',
     '0x3',
     '0x3',
     '0x5',
     '0x4',
     '0x6',
     '0x4',
     '0x2',
     '0x3',
     '0x5',
     '0x5',
     '0x1',
     '0x0',
     '0x3',
     '0x3',
     '0x7',
     '0x4',
     '0x1',
     '0x1',
     '0x4',
     '0x0',
     '0x2',
     '0x2',
     '0x1',
     '0x3',
     '0x7',
     '0x5',
     '0x0',
     '0x1',
     '0x0',
     '0x7',
     '0x7',
     '0x1',
     '0x3',
     '0x5',
     '0x6',
     '0x1',
     '0x1',
     '0x1',
     '0x4',
     '0x2',
     '0x0',
     '0x4',
     '0x1',
     '0x2',
     '0x7',
     '0x4',
     '0x4',
     '0x5',
     '0x6',
     '0x5',
     '0x2',
     '0x0',
     '0x3',
     '0x1',
     '0x0',
     '0x4',
     '0x3',
     '0x4',
     '0x5',
     '0x4',
     '0x7',
     '0x4',
     '0x5',
     '0x3',
     '0x1',
     '0x5',
     '0x5',
     '0x5',
     '0x2',
     '0x5',
     '0x4',
     '0x6',
     '0x2',
     '0x0',
     '0x7',
     '0x5',
     '0x1',
     '0x6',
     '0x3',
     '0x5',
     '0x1',
     '0x3',
     '0x0',
     '0x0',
     '0x2',
     '0x7',
     '0x3',
     '0x5',
     '0x4',
     '0x4',
     '0x5',
     '0x3',
     '0x5',
     '0x6',
     '0x6',
     '0x6',
     '0x0',
     '0x3',
     '0x2',
     '0x3',
     '0x4',
     '0x5',
     '0x7',
     '0x7',
     '0x5',
     '0x2',
     '0x0',
     '0x2',
     '0x6',
     '0x4',
     '0x1',
     '0x6',
     '0x0',
     '0x2',
     '0x1',
     '0x4',
     '0x5',
     '0x3',
     '0x1',
     '0x7',
     '0x0',
     '0x6',
     '0x5',
     '0x4',
     '0x6',
     '0x1',
     '0x5',
     '0x7',
     '0x3',
     '0x5',
     '0x0',
     '0x4',
     '0x6',
     '0x1',
     '0x0',
     '0x5',
     '0x4',
     '0x4',
     '0x3',
     '0x3',
     '0x7',
     '0x1',
     '0x3',
     '0x1',
     '0x5',
     '0x1',
     '0x6',
     '0x3',
     '0x1',
     '0x5',
     '0x3',
     '0x6',
     '0x6',
     '0x1',
     '0x2',
     '0x4',
     '0x5',
     '0x4',
     '0x5',
     '0x4',
     '0x6',
     '0x2',
     '0x4',
     '0x2',
     '0x7',
     '0x1',
     '0x6',
     '0x1',
     '0x5',
     '0x6',
     '0x5',
     '0x0',
     '0x5',
     '0x0',
     '0x1',
     '0x2',
     '0x7',
     '0x2',
     '0x1',
     '0x5',
     '0x0',
     '0x1',
     '0x0',
     '0x3',
     '0x0',
     '0x0',
     '0x4',
     '0x6',
     '0x3',
     '0x6',
     '0x1',
     '0x1',
     '0x0',
     '0x6',
     '0x3',
     '0x1',
     '0x5',
     '0x4',
     '0x5',
     '0x1',
     '0x0',
     '0x4',
     '0x1',
     '0x7',
     '0x7',
     '0x5',
     '0x5',
     '0x0',
     '0x7',
     '0x2',
     '0x7',
     '0x7',
     '0x6',
     '0x0',
     '0x6',
     '0x6',
     '0x3',
     '0x5',
     '0x5',
     '0x6',
     '0x5',
     '0x5',
     '0x7',
     '0x5',
     '0x5',
     '0x7',
     '0x1',
     '0x7',
     '0x7',
     '0x4',
     '0x6',
     '0x0',
     '0x1',
     '0x1',
     '0x5',
     '0x4',
     '0x0',
     '0x5',
     '0x6',
     '0x4',
     '0x5',
     '0x3',
     '0x5',
     '0x3',
     '0x4',
     '0x6',
     '0x3',
     '0x2',
     '0x4',
     '0x7',
     '0x6',
     '0x4',
     '0x2',
     '0x5',
     '0x3',
     '0x3',
     '0x1',
     '0x5',
     '0x0',
     '0x0',
     '0x7',
     '0x4',
     '0x4',
     '0x7',
     '0x0',
     '0x6',
     '0x3',
     '0x2',
     '0x7',
     '0x5',
     '0x7',
     '0x5',
     '0x0',
     '0x2',
     '0x6',
     '0x0',
     '0x2',
     '0x0',
     '0x2',
     '0x1',
     '0x6',
     '0x0',
     '0x1',
     '0x0',
     '0x1',
     '0x4',
     '0x4',
     '0x3',
     '0x7',
     '0x1',
     '0x3',
     '0x0',
     '0x4',
     '0x4',
     '0x2',
     '0x7',
     '0x0',
     '0x7',
     '0x4',
     '0x1',
     '0x6',
     '0x0',
     '0x1',
     '0x2',
     '0x5',
     '0x0',
     '0x7',
     '0x7',
     '0x0',
     '0x5',
     '0x3',
     '0x4',
     '0x1',
     '0x3',
     '0x2',
     '0x7',
     '0x5',
     '0x1',
     '0x5',
     '0x3',
     '0x4',
     '0x2',
     '0x4',
     '0x5',
     '0x2',
     '0x7',
     '0x1',
     '0x4',
     '0x0',
     '0x1',
     '0x4',
     '0x6',
     '0x3',
     '0x5',
     '0x1',
     '0x4',
     '0x5',
     '0x5',
     '0x2',
     '0x7',
     '0x5',
     '0x1',
     '0x5',
     '0x4',
     '0x3',
     '0x0',
     '0x1',
     '0x2',
     '0x1',
     '0x1',
     '0x1',
     '0x6',
     '0x7',
     '0x7',
     '0x3',
     '0x0',
     '0x0',
     '0x1',
     '0x4',
     '0x4',
     '0x5',
     '0x3',
     '0x7',
     '0x7',
     '0x3',
     '0x1',
     '0x1',
     '0x1',
     '0x3',
     '0x6',
     '0x2',
     '0x2',
     '0x2',
     '0x4',
     '0x1',
     '0x2',
     '0x4',
     '0x6',
     '0x1',
     '0x2',
     '0x5',
     '0x3',
     '0x7',
     '0x0',
     '0x1',
     '0x0',
     '0x0',
     '0x7',
     '0x4',
     '0x2',
     '0x6',
     '0x2']},
   'meas_level': 2,
   'header': {'qubit_labels': [['q', 0],
     ['q', 1],
     ['q', 2],
     ['q', 3],
     ['q', 4],
     ['q', 5],
     ['q', 6]],
    'n_qubits': 7,
    'qreg_sizes': [['q', 7]],
    'clbit_labels': [['c1', 0], ['crz', 0], ['crx', 0]],
    'memory_slots': 3,
    'creg_sizes': [['c1', 1], ['crz', 1], ['crx', 1]],
    'name': "('Y',)",
    'global_phase': 3.9269908169872414,
    'metadata': {}}},
  {'shots': 1000,
   'success': True,
   'data': {'counts': {'0x0': 157,
     '0x1': 160,
     '0x2': 96,
     '0x3': 105,
     '0x4': 108,
     '0x5': 134,
     '0x6': 119,
     '0x7': 121},
    'memory': ['0x2',
     '0x7',
     '0x4',
     '0x3',
     '0x7',
     '0x0',
     '0x3',
     '0x5',
     '0x7',
     '0x0',
     '0x1',
     '0x0',
     '0x0',
     '0x1',
     '0x0',
     '0x4',
     '0x6',
     '0x1',
     '0x0',
     '0x3',
     '0x7',
     '0x0',
     '0x6',
     '0x7',
     '0x6',
     '0x7',
     '0x2',
     '0x0',
     '0x2',
     '0x1',
     '0x6',
     '0x5',
     '0x2',
     '0x0',
     '0x7',
     '0x6',
     '0x2',
     '0x1',
     '0x6',
     '0x0',
     '0x6',
     '0x0',
     '0x0',
     '0x1',
     '0x0',
     '0x1',
     '0x4',
     '0x6',
     '0x1',
     '0x2',
     '0x6',
     '0x4',
     '0x0',
     '0x2',
     '0x7',
     '0x0',
     '0x0',
     '0x5',
     '0x3',
     '0x2',
     '0x3',
     '0x0',
     '0x1',
     '0x2',
     '0x0',
     '0x7',
     '0x3',
     '0x6',
     '0x1',
     '0x4',
     '0x0',
     '0x4',
     '0x5',
     '0x2',
     '0x6',
     '0x7',
     '0x1',
     '0x0',
     '0x6',
     '0x7',
     '0x0',
     '0x3',
     '0x6',
     '0x5',
     '0x0',
     '0x2',
     '0x3',
     '0x3',
     '0x1',
     '0x0',
     '0x0',
     '0x0',
     '0x6',
     '0x7',
     '0x1',
     '0x0',
     '0x6',
     '0x1',
     '0x6',
     '0x0',
     '0x4',
     '0x3',
     '0x7',
     '0x6',
     '0x6',
     '0x5',
     '0x7',
     '0x5',
     '0x5',
     '0x7',
     '0x5',
     '0x7',
     '0x0',
     '0x7',
     '0x5',
     '0x3',
     '0x6',
     '0x5',
     '0x3',
     '0x0',
     '0x1',
     '0x6',
     '0x5',
     '0x7',
     '0x6',
     '0x5',
     '0x0',
     '0x2',
     '0x7',
     '0x1',
     '0x2',
     '0x5',
     '0x0',
     '0x3',
     '0x0',
     '0x7',
     '0x5',
     '0x2',
     '0x6',
     '0x1',
     '0x0',
     '0x7',
     '0x1',
     '0x6',
     '0x2',
     '0x7',
     '0x4',
     '0x1',
     '0x0',
     '0x3',
     '0x4',
     '0x6',
     '0x5',
     '0x7',
     '0x1',
     '0x3',
     '0x5',
     '0x5',
     '0x6',
     '0x2',
     '0x7',
     '0x5',
     '0x7',
     '0x7',
     '0x1',
     '0x1',
     '0x0',
     '0x5',
     '0x5',
     '0x7',
     '0x5',
     '0x0',
     '0x5',
     '0x7',
     '0x4',
     '0x2',
     '0x3',
     '0x0',
     '0x4',
     '0x1',
     '0x7',
     '0x1',
     '0x1',
     '0x2',
     '0x3',
     '0x4',
     '0x5',
     '0x5',
     '0x6',
     '0x4',
     '0x6',
     '0x0',
     '0x7',
     '0x5',
     '0x6',
     '0x7',
     '0x5',
     '0x7',
     '0x0',
     '0x1',
     '0x2',
     '0x6',
     '0x0',
     '0x3',
     '0x1',
     '0x4',
     '0x4',
     '0x7',
     '0x3',
     '0x0',
     '0x0',
     '0x6',
     '0x0',
     '0x3',
     '0x1',
     '0x5',
     '0x5',
     '0x4',
     '0x1',
     '0x1',
     '0x0',
     '0x5',
     '0x3',
     '0x5',
     '0x0',
     '0x1',
     '0x0',
     '0x7',
     '0x4',
     '0x6',
     '0x7',
     '0x1',
     '0x6',
     '0x1',
     '0x1',
     '0x1',
     '0x7',
     '0x2',
     '0x2',
     '0x3',
     '0x7',
     '0x0',
     '0x3',
     '0x5',
     '0x1',
     '0x0',
     '0x5',
     '0x0',
     '0x1',
     '0x0',
     '0x1',
     '0x0',
     '0x5',
     '0x2',
     '0x4',
     '0x0',
     '0x3',
     '0x3',
     '0x4',
     '0x1',
     '0x7',
     '0x1',
     '0x1',
     '0x1',
     '0x5',
     '0x1',
     '0x5',
     '0x4',
     '0x5',
     '0x1',
     '0x6',
     '0x1',
     '0x0',
     '0x0',
     '0x4',
     '0x7',
     '0x0',
     '0x2',
     '0x3',
     '0x4',
     '0x1',
     '0x0',
     '0x3',
     '0x1',
     '0x5',
     '0x6',
     '0x3',
     '0x6',
     '0x0',
     '0x0',
     '0x1',
     '0x1',
     '0x7',
     '0x0',
     '0x5',
     '0x3',
     '0x5',
     '0x0',
     '0x2',
     '0x3',
     '0x7',
     '0x7',
     '0x0',
     '0x1',
     '0x3',
     '0x6',
     '0x5',
     '0x1',
     '0x1',
     '0x6',
     '0x2',
     '0x4',
     '0x2',
     '0x4',
     '0x2',
     '0x5',
     '0x5',
     '0x4',
     '0x4',
     '0x5',
     '0x3',
     '0x3',
     '0x1',
     '0x7',
     '0x0',
     '0x7',
     '0x5',
     '0x5',
     '0x1',
     '0x5',
     '0x6',
     '0x5',
     '0x1',
     '0x7',
     '0x2',
     '0x6',
     '0x1',
     '0x6',
     '0x4',
     '0x3',
     '0x5',
     '0x1',
     '0x7',
     '0x0',
     '0x5',
     '0x3',
     '0x7',
     '0x2',
     '0x1',
     '0x3',
     '0x7',
     '0x2',
     '0x2',
     '0x2',
     '0x0',
     '0x4',
     '0x4',
     '0x5',
     '0x3',
     '0x2',
     '0x5',
     '0x7',
     '0x3',
     '0x2',
     '0x0',
     '0x7',
     '0x3',
     '0x3',
     '0x5',
     '0x7',
     '0x2',
     '0x7',
     '0x5',
     '0x0',
     '0x2',
     '0x2',
     '0x2',
     '0x1',
     '0x6',
     '0x7',
     '0x1',
     '0x4',
     '0x0',
     '0x5',
     '0x1',
     '0x7',
     '0x1',
     '0x4',
     '0x5',
     '0x1',
     '0x2',
     '0x1',
     '0x6',
     '0x5',
     '0x0',
     '0x4',
     '0x1',
     '0x0',
     '0x1',
     '0x0',
     '0x5',
     '0x1',
     '0x5',
     '0x0',
     '0x1',
     '0x0',
     '0x2',
     '0x6',
     '0x1',
     '0x2',
     '0x1',
     '0x4',
     '0x1',
     '0x0',
     '0x6',
     '0x2',
     '0x5',
     '0x6',
     '0x3',
     '0x6',
     '0x0',
     '0x6',
     '0x0',
     '0x5',
     '0x7',
     '0x3',
     '0x2',
     '0x7',
     '0x5',
     '0x5',
     '0x0',
     '0x6',
     '0x4',
     '0x4',
     '0x5',
     '0x2',
     '0x0',
     '0x0',
     '0x7',
     '0x3',
     '0x7',
     '0x0',
     '0x3',
     '0x2',
     '0x1',
     '0x6',
     '0x1',
     '0x0',
     '0x6',
     '0x2',
     '0x0',
     '0x2',
     '0x5',
     '0x7',
     '0x0',
     '0x7',
     '0x1',
     '0x5',
     '0x6',
     '0x7',
     '0x5',
     '0x7',
     '0x7',
     '0x7',
     '0x0',
     '0x7',
     '0x0',
     '0x0',
     '0x0',
     '0x2',
     '0x2',
     '0x6',
     '0x0',
     '0x4',
     '0x7',
     '0x6',
     '0x0',
     '0x7',
     '0x1',
     '0x6',
     '0x6',
     '0x1',
     '0x0',
     '0x3',
     '0x1',
     '0x5',
     '0x2',
     '0x6',
     '0x1',
     '0x7',
     '0x0',
     '0x3',
     '0x4',
     '0x5',
     '0x3',
     '0x7',
     '0x6',
     '0x1',
     '0x4',
     '0x0',
     '0x2',
     '0x6',
     '0x7',
     '0x2',
     '0x1',
     '0x2',
     '0x6',
     '0x6',
     '0x0',
     '0x7',
     '0x4',
     '0x0',
     '0x6',
     '0x5',
     '0x1',
     '0x3',
     '0x7',
     '0x1',
     '0x4',
     '0x4',
     '0x1',
     '0x7',
     '0x1',
     '0x1',
     '0x5',
     '0x7',
     '0x7',
     '0x5',
     '0x0',
     '0x5',
     '0x0',
     '0x2',
     '0x0',
     '0x7',
     '0x3',
     '0x6',
     '0x4',
     '0x6',
     '0x4',
     '0x0',
     '0x5',
     '0x4',
     '0x4',
     '0x5',
     '0x3',
     '0x5',
     '0x7',
     '0x4',
     '0x7',
     '0x0',
     '0x4',
     '0x1',
     '0x7',
     '0x1',
     '0x5',
     '0x3',
     '0x0',
     '0x4',
     '0x4',
     '0x0',
     '0x0',
     '0x6',
     '0x7',
     '0x3',
     '0x6',
     '0x2',
     '0x7',
     '0x5',
     '0x3',
     '0x0',
     '0x0',
     '0x3',
     '0x5',
     '0x0',
     '0x0',
     '0x3',
     '0x3',
     '0x1',
     '0x2',
     '0x2',
     '0x4',
     '0x7',
     '0x2',
     '0x4',
     '0x0',
     '0x1',
     '0x6',
     '0x1',
     '0x5',
     '0x1',
     '0x6',
     '0x3',
     '0x0',
     '0x1',
     '0x3',
     '0x0',
     '0x6',
     '0x4',
     '0x7',
     '0x1',
     '0x4',
     '0x4',
     '0x0',
     '0x2',
     '0x3',
     '0x7',
     '0x1',
     '0x4',
     '0x6',
     '0x1',
     '0x5',
     '0x0',
     '0x7',
     '0x4',
     '0x0',
     '0x3',
     '0x5',
     '0x2',
     '0x4',
     '0x1',
     '0x4',
     '0x0',
     '0x4',
     '0x3',
     '0x5',
     '0x6',
     '0x4',
     '0x2',
     '0x0',
     '0x1',
     '0x6',
     '0x4',
     '0x1',
     '0x7',
     '0x2',
     '0x0',
     '0x0',
     '0x6',
     '0x5',
     '0x1',
     '0x4',
     '0x3',
     '0x0',
     '0x1',
     '0x0',
     '0x4',
     '0x3',
     '0x4',
     '0x0',
     '0x1',
     '0x7',
     '0x5',
     '0x4',
     '0x5',
     '0x6',
     '0x1',
     '0x7',
     '0x1',
     '0x4',
     '0x4',
     '0x0',
     '0x7',
     '0x0',
     '0x1',
     '0x4',
     '0x4',
     '0x4',
     '0x1',
     '0x1',
     '0x1',
     '0x3',
     '0x0',
     '0x1',
     '0x3',
     '0x2',
     '0x2',
     '0x2',
     '0x5',
     '0x3',
     '0x5',
     '0x6',
     '0x1',
     '0x0',
     '0x3',
     '0x6',
     '0x6',
     '0x7',
     '0x6',
     '0x1',
     '0x6',
     '0x1',
     '0x5',
     '0x3',
     '0x0',
     '0x5',
     '0x7',
     '0x7',
     '0x2',
     '0x5',
     '0x4',
     '0x6',
     '0x4',
     '0x6',
     '0x2',
     '0x4',
     '0x3',
     '0x6',
     '0x0',
     '0x7',
     '0x2',
     '0x3',
     '0x1',
     '0x6',
     '0x6',
     '0x1',
     '0x7',
     '0x3',
     '0x5',
     '0x3',
     '0x4',
     '0x4',
     '0x5',
     '0x4',
     '0x6',
     '0x6',
     '0x0',
     '0x3',
     '0x4',
     '0x0',
     '0x0',
     '0x2',
     '0x6',
     '0x3',
     '0x5',
     '0x6',
     '0x3',
     '0x0',
     '0x1',
     '0x4',
     '0x4',
     '0x1',
     '0x5',
     '0x7',
     '0x3',
     '0x1',
     '0x3',
     '0x1',
     '0x4',
     '0x7',
     '0x6',
     '0x0',
     '0x6',
     '0x5',
     '0x3',
     '0x3',
     '0x5',
     '0x0',
     '0x4',
     '0x2',
     '0x0',
     '0x5',
     '0x1',
     '0x1',
     '0x6',
     '0x5',
     '0x0',
     '0x1',
     '0x6',
     '0x2',
     '0x5',
     '0x1',
     '0x1',
     '0x2',
     '0x4',
     '0x3',
     '0x1',
     '0x5',
     '0x7',
     '0x6',
     '0x2',
     '0x4',
     '0x5',
     '0x2',
     '0x0',
     '0x6',
     '0x1',
     '0x2',
     '0x2',
     '0x1',
     '0x0',
     '0x6',
     '0x5',
     '0x7',
     '0x4',
     '0x7',
     '0x7',
     '0x0',
     '0x2',
     '0x3',
     '0x3',
     '0x2',
     '0x1',
     '0x2',
     '0x4',
     '0x0',
     '0x6',
     '0x6',
     '0x5',
     '0x6',
     '0x1',
     '0x7',
     '0x6',
     '0x4',
     '0x6',
     '0x5',
     '0x0',
     '0x5',
     '0x0',
     '0x0',
     '0x3',
     '0x1',
     '0x5',
     '0x0',
     '0x5',
     '0x0',
     '0x4',
     '0x3',
     '0x5',
     '0x4',
     '0x5',
     '0x3',
     '0x7',
     '0x3',
     '0x7',
     '0x3',
     '0x1',
     '0x6',
     '0x3',
     '0x6',
     '0x1',
     '0x1',
     '0x1',
     '0x2',
     '0x5',
     '0x0',
     '0x4',
     '0x4',
     '0x3',
     '0x0',
     '0x7',
     '0x0',
     '0x2',
     '0x1',
     '0x5',
     '0x6',
     '0x4',
     '0x7',
     '0x7',
     '0x7',
     '0x5',
     '0x0',
     '0x3',
     '0x0',
     '0x0',
     '0x7',
     '0x5',
     '0x0',
     '0x2',
     '0x1',
     '0x3',
     '0x4',
     '0x4',
     '0x1',
     '0x2',
     '0x1',
     '0x4',
     '0x2',
     '0x6',
     '0x5',
     '0x0',
     '0x5',
     '0x0',
     '0x5',
     '0x5',
     '0x1',
     '0x4',
     '0x4',
     '0x6',
     '0x2',
     '0x6',
     '0x4',
     '0x2',
     '0x2',
     '0x0',
     '0x6',
     '0x5',
     '0x1',
     '0x6',
     '0x7',
     '0x6',
     '0x1',
     '0x1',
     '0x4',
     '0x1',
     '0x4',
     '0x7',
     '0x5',
     '0x0',
     '0x6',
     '0x6',
     '0x0',
     '0x2',
     '0x7',
     '0x5',
     '0x2',
     '0x4',
     '0x5',
     '0x7',
     '0x6',
     '0x4',
     '0x1',
     '0x5',
     '0x3',
     '0x6',
     '0x5',
     '0x1',
     '0x2',
     '0x7',
     '0x1',
     '0x3',
     '0x1',
     '0x7',
     '0x5',
     '0x0',
     '0x6',
     '0x7',
     '0x6',
     '0x1',
     '0x5',
     '0x3',
     '0x4',
     '0x6',
     '0x4',
     '0x1',
     '0x4',
     '0x1',
     '0x7',
     '0x1',
     '0x5',
     '0x1',
     '0x1',
     '0x5',
     '0x6',
     '0x3',
     '0x5',
     '0x3',
     '0x3',
     '0x3',
     '0x3',
     '0x7',
     '0x6',
     '0x1',
     '0x7',
     '0x5',
     '0x0',
     '0x1',
     '0x2',
     '0x3',
     '0x6',
     '0x2',
     '0x3',
     '0x4',
     '0x5',
     '0x5',
     '0x1',
     '0x1',
     '0x7',
     '0x3',
     '0x2',
     '0x4',
     '0x0',
     '0x5',
     '0x4',
     '0x2',
     '0x1',
     '0x5',
     '0x4',
     '0x1',
     '0x0',
     '0x7',
     '0x1',
     '0x1',
     '0x7',
     '0x3',
     '0x6',
     '0x3',
     '0x3',
     '0x2',
     '0x2',
     '0x1']},
   'meas_level': 2,
   'header': {'qubit_labels': [['q', 0],
     ['q', 1],
     ['q', 2],
     ['q', 3],
     ['q', 4],
     ['q', 5],
     ['q', 6]],
    'n_qubits': 7,
    'qreg_sizes': [['q', 7]],
    'clbit_labels': [['c1', 0], ['crz', 0], ['crx', 0]],
    'memory_slots': 3,
    'creg_sizes': [['c1', 1], ['crz', 1], ['crx', 1]],
    'name': "('Z',)",
    'global_phase': 3.9269908169872414,
    'metadata': {}}}],
 'date': {'__type__': 'datetime', '__value__': '2022-05-11T00:28:30+00:00'},
 'status': 'Successful completion',
 'header': {},
 'execution_id': '46736c5e-d0c1-11ec-bd42-b02628ea1e00',
 'time_taken': 6.787487268447876,
 'error': None}


result = Result.from_dict(result_dict)
marginal_counts(result, indices=[2])
```
</details>

### What should happen?

Code should execute successfully and marginalize the counts.

### Any suggestions?

_No response_


Discussion:

Resolving patch:
diff --git a/qiskit/result/utils.py b/qiskit/result/utils.py
--- a/qiskit/result/utils.py
+++ b/qiskit/result/utils.py
@@ -80,7 +80,7 @@ def marginal_counts(
                     )  # same convention as for the counts
                     bit_strings = [_hex_to_bin(s) for s in experiment_result.data.memory]
                     marginal_bit_strings = [
-                        "".join([s[-idx - 1] for idx in sorted_indices if idx < len(s)])
+                        "".join([s[-idx - 1] for idx in sorted_indices if idx < len(s)]) or "0"
                         for s in bit_strings
                     ]
                     experiment_result.data.memory = [_bin_to_hex(s) for s in marginal_bit_strings]


Test patch:
diff --git a/test/python/result/test_result.py b/test/python/result/test_result.py
--- a/test/python/result/test_result.py
+++ b/test/python/result/test_result.py
@@ -222,6 +222,16 @@ def test_marginal_counts_result_memory(self):
         marginal_memory = marginal_result.results[0].data.memory
         self.assertEqual(marginal_memory, [hex(ii % 2) for ii in range(8)])
 
+    def test_marginal_counts_result_memory_nonzero_indices(self):
+        """Test that a Result object containing memory marginalizes correctly."""
+        result = self.generate_qiskit_result()
+        index = 2
+        marginal_result = marginal_counts(result, indices=[index])
+        marginal_memory = marginal_result.results[0].data.memory
+        mask = 1 << index
+        expected = [hex((ii & mask) >> index) for ii in range(8)]
+        self.assertEqual(marginal_memory, expected)
+
     def test_marginal_counts_result_memory_indices_None(self):
         """Test that a Result object containing memory marginalizes correctly."""
         result = self.generate_qiskit_result()