# How to sum every element but one

**URL:** <https://discourse.julialang.org/t/how-to-sum-every-element-but-one/49771>\
**Category:** General Usage\
**Tags:** question\
**Created:** [November 8, 2020, 7:18am UTC](https://discourse.julialang.org/t/how-to-sum-every-element-but-one/49771 "2020-11-08T07:18:36Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![greg\_plowman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/greg_plowman/32/8100_2.png) [@greg\_plowman](https://discourse.julialang.org/u/greg_plowman)\
**Post date:** [November 8, 2020, 7:25am UTC](https://discourse.julialang.org/t/how-to-sum-every-element-but-one/49771/3 "2020-11-08T07:25:18Z")

</div>

`sum(x[i] for i in I if i != j)`

---

_[View the full topic](https://discourse.julialang.org/t/how-to-sum-every-element-but-one/49771)._
