An electronic device comprising: a foldable housing comprising: a first housing; a second housing connected to one side of the first housing and being rotatable through a first hinge module and disposed to at least partially face the first housing in a folded state; and a third housing connected to an opposite side of the first housing and being rotatable through a second hinge module and disposed to at least partially face the first housing in a folded state, wherein, in a folded state, the foldable housing further comprises: a pen accommodating part defined through a spaced space between a first edge of the second housing and a second edge of the third housing; a flexible display extending from at least a portion of the second housing to at least a portion of the third housing through the first housing; and an electronic pen at least partially accommodated in the pen accommodating part and comprising at least one magnetic force reaction member (310, 320) inside the electronic pen, wherein the electronic device further comprises at least one magnetic force generating member (225, 235) disposed around the first edge of the second housing and/or the second edge of the third housing, and wherein, when the electronic pen is mounted in the pen accommodating part, the location of the electronic pen is maintained through the magnetic force reaction member (310, 320). a foldable housing comprising: a first housing; a second housing connected to one side of the first housing and being rotatable through a first hinge module and disposed to at least partially face the first housing in a folded state; and a third housing connected to an opposite side of the first housing and being rotatable through a second hinge module and disposed to at least partially face the first housing in a folded state, wherein, in a folded state, the foldable housing further comprises: a pen accommodating part defined through a spaced space between a first edge of the second housing and a second edge of the third housing; a first housing; a second housing connected to one side of the first housing and being rotatable through a first hinge module and disposed to at least partially face the first housing in a folded state; and a third housing connected to an opposite side of the first housing and being rotatable through a second hinge module and disposed to at least partially face the first housing in a folded state, wherein, in a folded state, the foldable housing further comprises: a pen accommodating part defined through a spaced space between a first edge of the second housing and a second edge of the third housing; a flexible display extending from at least a portion of the second housing to at least a portion of the third housing through the first housing; and an electronic pen at least partially accommodated in the pen accommodating part and comprising at least one magnetic force reaction member (310, 320) inside the electronic pen, wherein the electronic device further comprises at least one magnetic force generating member (225, 235) disposed around the first edge of the second housing and/or the second edge of the third housing, and wherein, when the electronic pen is mounted in the pen accommodating part, the location of the electronic pen is maintained through the magnetic force reaction member (310, 320).