Complex sentence: In July 1940 she became part of the "21st U-boat Flotilla" as a training boat until 16 March 1945 when she became part of the "31st U-boat Flotilla" (training) until 2 May 1945 when she was scuttled at Bremerhaven.
Split into simpler sentences: In July 1940 she became part of the "21st U-boat Flotilla" "(school boat)" until 16 March 1945. In March 1945 she became part of the "31st U-boat Flotilla" (training) until 2 May 1945 when she was scuttled at Bremerhaven.