4.基本編-関数(Python)

関数

range

range(start, stop[, step])

for i in range(1, 10):
    print(i)
    
for _ in range(10):
    print('Python')

enumerate

enumerate(iterable[, start=0])
(0, seq[0]), (1, seq[1]), (2, seq[2]), ...

for i, word in enumerate(['My', 'name', 'is', 'mnz']):
    print(i, word)

zip

zip(*iterables) --> zip object
(seq1[0], seq2[0], seq3[0] ...), (seq1[1], seq2[1], seq3[1] ...), ...

Name = ['Tanaka', 'Sato', 'Suzuki']
Math_score = [80, 60, 100]
English_score = [60, 90, 30]

for Name, Math_score, English_score in zip(Name, Math_score, English_score):
    print(Name, Math_score, English_score)