zip関数(便利)
| 登録日 | :2024/08/28 04:46 |
|---|---|
| カテゴリ | :Python基礎 |
Zip関数を使うことで、複数のリストを同時にループすることができる。
days = ['Tes', 'Wed', 'Thu']
fruits = ['apple', 'banana', 'lemon']
drinks = ['coffee', 'tea', 'juice']
for day, fruit, drink in zip(days, fruits, drinks):
print(day, fruit, drink)
Tes apple coffee
Wed banana tea
Thu lemon juice
Process finished with exit code 0