A measurement is presented of elliptic (v2) and triangular (v3) azimuthal anisotropy coefficients for charged particles produced in Pb+Pb collisions at sNN=5.02 TeV using a dataset corresponding to an integrated luminosity of 0.44nb−1 collected with the ATLAS detector at the LHC in 2018. The values of v2 and v3 are measured for charged particles over a wide range of transverse momentum (pT), 1–400 GeV, and Pb+Pb collision centrality, 0–60%, using the scalar-product and multiparticle cumulant methods. These methods are sensitive to event-by-event fluctuations and nonflow effects in the measurements of azimuthal anisotropies. Positive values of v2 are observed up to a pT of approximately 100 GeV from both methods across all centrality intervals. Positive values of v3 are observed up to approximately 25 GeV using both methods, though the application of the three-subevent technique to the multiparticle cumulant method leads to significant changes at the highest pT. At high pT (pT⪆10 GeV), charged particles are dominantly from jet fragmentation. These jets, and hence the measurements presented here, are sensitive to the path-length dependence of parton energy loss in the quark-gluon plasma produced in Pb+Pb collisions.