title: How to read a component in YAML file so that I can edit it's key value using ruamel.yaml?
body: <p>This is my YAML file (<code>input.yaml</code>):</p>
  
  <pre><code>team_member:
    name: Max
    hobbies:
      - Reading
  
  team_leader:
    name: Stuart
    hobbies:
      - dancing
  </code></pre>
  
  <p>I want to edit this YAML file to add more values in key 'hobbies', example:</p>
  
  <pre><code>team_member:
    name: Max
    hobbies:
      - Reading
      - Painting
  
  team_leader:
    name: Stuart
    hobbies:
      - Dancing
      - Fishing
  </code></pre>
  
  <p>I tried to implement the code <a href="https://stackoverflow.com/a/49767944">Anthon</a> to fit my situation but it didn't helped at all, because the indention level of that YAML file is different from mine.<br>
  Example:</p>
  
  <pre><code>import sys
  import ruamel.yaml
  
  yaml = ruamel.yaml.YAML()
  # yaml.preserve_quotes = True
  with open('input.yaml') as fp:
      data = yaml.load(fp)
  for elem in data:
      if elem['name'] == 'Stuart':
           elem['hobbies'] = ['Fishing']
           break  # no need to iterate further
  yaml.dump(data, sys.stdout)
  </code></pre>
  
  <p>I get error "TypeError('string indices must be integers',)", I know this code might be completely wrong, but I am new to ruamel.yaml.</p>
  
  <p>How to code this? </p>