Python is a versatile and powerful programming language that provides various ways to manipulate and combine data structures. One common…