The life of a star is dominantly determined by the physical processes in the stellar interior. Unfortunately, we still have a poor understanding of how the stellar gas mixes near the stellar core, preventing precise predictions of stellar evolution. The unknown nature of the mixing processes as well as the extent of the central mixed region is particularly problematic for massive stars. Oscillations in stars with masses a few times that of the Sun offer a unique opportunity to disentangle the nature of various mixing processes, through the distinct signature they leave on period spacings in the gravity mode spectrum. Here we report the detection of numerous gravity modes in a young star with a mass of about seven solar masses. The mean period spacing allows us to estimate the extent of the convective core, and the clear periodic deviation from the mean constrains the location of the chemical transition zone to be at about 10 per cent of the radius and rules out a clear-cut profile.