Dictionary Comprehensions

This commit is contained in:
Mert Gör 🇹🇷 2023-06-12 14:04:05 +03:00
parent c90a0d2705
commit 68805b2d4b
No known key found for this signature in database
GPG Key ID: 2100A876D55B39B9
2 changed files with 7 additions and 0 deletions

View File

@ -0,0 +1,5 @@
d = {}
for i in [1, 2, 3, 4]:
d[i] = str(i)
print(d)

View File

@ -0,0 +1,2 @@
d = {i: str(i) for i in [1, 2, 3, 4, 5] }
print(d)