Paste Search Dynamic
Recent pastes
ex11
1. def ex11():
2.     couleur = [" pique"," coeur"," trÃ¨fle"," carreau"]
3.     #jeu = [str(i)+item for item in couleur for i in range(2,14)]
4.     #print(jeu)
5.
6. #ex11()
7. def ex13():
8.     t= [2,100,54.2,10]
9.     res =[]
10.     for x in t:
11.         if x>=10 and x <= 100:
12.             res.append(x)
13. #ex13()
14.
15. def ex14():
16.     t= [1,2,4,6]
17.     t_pair =[item for item in t if item % 2 ==0]
18.     print(t_pair)
19.     t_pair_idx= [index for index in range(len(t)) if t[index] in t_pair==true]
20.     print(t_pair_idx)
21. #ex14()
22.
23. def ex20(list,i,j):
24.     a=list[i]
25.     b=list[j]
26.     try:
27.         list.insert(j, a)
28.         if i>j:
29.             list.pop(i+1)
30.             list.insert(i+1, b)
31.             list.pop(j+1)
32.         else:
33.             list.pop(i)
34.             list.insert(i, b)
35.             list.pop(j+1)
36.     except indexerror:
37.         print("impossible")
38.     return list
39. print(ex20([1,2,3,4,5],2,4))
Parsed in 0.005 seconds