logo
Python Base : Trucs et Astuces

EN CONSTRUCTION

ALPHA = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
phrase = input()
d_occ = {lettre:phrase.count(lettre) for lettre in ALPHA}

from time import time
N = 10000000

t = time()
t1 = [0]*N
print("Initialisation directe:", time() - t)

t = time()
t2 = []
for _ in range(N):
    t2.append(0)
print("Avec append: ", time() - t)

ALPHA = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
phrase = input()
d_occ = {lettre:phrase.count(lettre) for lettre in ALPHA}
#A la tableau
T = [0] * 10
for i in range(10): T[i] = 2*i + 1

# à la liste :

T= []
for i in range(10): T.append(2*i + 1)

#par compréhension :

T = [ 2*i + 1 for i in range(10) ]