Sign of work done by gas during isothermal expansion $\pu{10 mol}$ of an ideal gas confined to a volume of $\pu{10 L}$ is released into atmosphere at $\pu{300 K}$ where the pressure is $\pu{1 bar}.$ The work done by the gas is:

Work done can be found as
$$W = -p_\mathrm{ext}(V_\mathrm{f} - V_\mathrm{i}).\tag{1}$$
$$V_\mathrm{f} = \frac{nRT}{p} = \frac{\pu{10 mol}\times\pu{0.083 L bar K^-1 mol^-1}\times\pu{300 K}}{\pu{1 bar}} = \pu{249 L}\tag{2},$$
$$W = -\pu{1 bar}\cdot(\pu{249 L} - \pu{10 L}) = \pu{-239 bar L}\tag{3}$$
As the question is asking us to find the work done by the gas, so shouldn't it be $\pu{+239 bar L},$ as work done by the gas is negative of the word done by external pressure?
But someone told me that the work done calculated is the work done by the gas and $\pu{-239 bar L}$ should be the answer. So, what mistake am I making and how do I determine if work done by the gas (and external pressure) is positive or negative under different conditions (expansion and compression)?
P.S.$\pu{-239 bar L}$ is the answer according to the answer key.
If we imagine our proverbial, frictionless piston containing some ideal gas, when $P_{surr} &gt; P_{syst}$, the system is compressed by the piston and work is done on the system by the surroundings (i.e. work is positive). If the reverse is true ($P_{syst} &gt; P_{surr}$), the gas in the piston will expand and work is done on the surroundings by the system (work is negative)
If you think of it in terms of internal energy, it might help. When work is done on the system, the internal energy increases for the ideal gas in the system (work is positive, internal energy increases). When the system does work on the surroundings (expansion), its ability to do work decreases (internal energy decreases, work is negative).
Hope this helps.