Q:

How to form a given list of elements in python to create another set of lists from it?

List1 =['000095', '000094', '000092', '000101', '000099', '000096', '000095']

def makecycle(list, startElement):
A loop which forms the bottom list which is made from the upper one's elements! 
if i pass that function the start element and the list it shoul print like this:
makecycle(list1, 000094) it should print:
['000094', '000092', '000101', '000099', '000096', '000095', '000094']
and if pass 
makecycle(list1, 000101) it should print:
['000101', '000099', '000096', '000095', '000094', '000092', '000101']

and if pass 
makecycle(list1, 000092) it should print:
['000092', '000101', '000099', '000096', '000095', '000094', '000092']

i know its kinda not clear enough but thats all i can point!

A:

def makecycle(list1,startElement):
   ind = list1.index(startElement)
   l = len(list1)
   i = ind
   list2 = []
   while ind < (l-1):
      list2.append(list1[ind])
      ind = ind + 1

   for x in range(i):
       if list1[x] not in list2:
          list2.append(list1[x])

   print(list2)

