## Thursday, May 20, 2021

Solution Exercise 33: Python program which performs a circular permutation on a list #### Exercise 33

Write a Python program as a function which takes a list L as a parameter and returns the list obtained by performing a circular permutation on the list L. Example if L = [41, 11, 34, 20, 18, 6], the program returns: the list: [6, 41, 11, 34, 20, 18]

#### Solution

``````def circularPermutation (L):
# initialization of the list obtained via a circular permutation of L
circlarList = []
for i in range (1, len (L)):
circlarList.append (L [i-1])
# insert the last element in the first position
circlarList.insert (0, L [-1])
return circlarList

L = [41, 11, 34, 20, 18, 6]
print (circularPermutation (L))
# Displays: [6, 41, 11, 34, 20, 18]``````

Younes Derfoufi
my-courses.net

## Python Exercises With Solutions

1. Python Arithmetic Exercises
2. Equations & System Of Equations
3. Polynomials and Functions
4. Python Arithmetic Exercises
5. Numpy, Matplolib, Sympy , Scipy - Exercises
6. Python Arithmetic Exercises

Younes Derfoufi

## Sample Text 