list_A = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
while list_A:
el = list_A.pop()
print(el)
if 'c'==el:
break
print("job done.")
, 'c' , , . 'c' , .
Based on @MSeifert's comment, if the loop should not stop at the first c, then instead it stops whenever there is no list c, a small modification of the above code leads to:
list_A = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'c', 'h', 'i', 'j']
while list_A:
print(list_A.pop())
if 'c' not in list_A:
break
print("job done.")
We could go faster, but I don’t know how you learned to cut the list and the compromise, but here is the best and quickest solution:
list_A = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
try:
p=list_A.index('c')
r='\n'.join(list_A[list_A.index('c'):][::-1])
except ValueError:
r='\n'.join(list_A[::-1])
print(r)
print('job done.')