# Looping to create new Branches with different data

**URL:** <https://root-forum.cern.ch/t/looping-to-create-new-branches-with-different-data/51044>\
**Category:** Newbie\
**Created:** [August 2, 2022, 2:16pm UTC](https://root-forum.cern.ch/t/looping-to-create-new-branches-with-different-data/51044 "2022-08-02T14:16:50Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [August 2, 2022, 6:06pm UTC](https://root-forum.cern.ch/t/looping-to-create-new-branches-with-different-data/51044/2 "2022-08-02T18:06:03Z")

</div>

You need `branch=tree.Branch(...)` and then `branch.Fill()` instead of `tree.Fill()`.

BTW. Ensure all branches have precisely the same number of entries (otherwise, expect problems with your tree later).

---

_[View the full topic](https://root-forum.cern.ch/t/looping-to-create-new-branches-with-different-data/51044)._
