Motivated by the technical and economic difficulties in further miniaturizing silicon-based transistors with the present fabrication technologies, there is a strong effort to develop alternative electronic devices, based, for example, on single molecules. Recently, carbon nanotubes have been successfully used for nanometre-sized devices such as diodes, transistors, and random access memory cells. Such nanotube devices are usually very long compared to silicon-based transistors. Here we report a method for dividing a semiconductor nanotube into multiple quantum dots with lengths of about 10 nm by inserting Gd@C82 endohedral fullerenes. The spatial modulation of the nanotube electronic bandgap is observed with a low-temperature scanning tunnelling microscope. We find that a bandgap of ∼0.5 eV is narrowed down to ∼0.1 eV at sites where endohedral metallofullerenes are inserted. This change in bandgap can be explained by local elastic strain and charge transfer at metallofullerene sites. This technique for fabricating an array of quantum dots could be used for nano-electronics and nano-optoelectronics.