Sözlük İçlemleri örnekleri

This commit is contained in:
Mert Gör 🇹🇷 2023-06-12 14:38:00 +03:00
parent 7768f84ed2
commit 824faa026d
No known key found for this signature in database
GPG key ID: 2100A876D55B39B9
4 changed files with 13 additions and 0 deletions

View file

@ -0,0 +1,3 @@
l = [('ali', 123, 1982), ('veli', 65, 1970), ('selami', 340, 1990), ('ayşe', 71, 1969)]
d = {name: (no, year) for name, no, year in l}
print(d)

View file

@ -0,0 +1,3 @@
d1 = {'ali': 123, 'veli': 432, 'selami': 892, 'ayşe': 45, 'fatma': 574}
d2 = {d1[key]: key for key in d1}
print(d2)

View file

@ -0,0 +1,4 @@
d1 = {'ali': 123, 'veli': 432, 'selami': 892, 'ayşe': 45, 'fatma': 574}
d2 = {d1[key]: key for key in d1}
)
print(d2

View file

@ -0,0 +1,3 @@
d1 = {'ali': 123, 'veli': 432, 'selami': 892, 'ayşe': 45, 'fatma': 574}
d2 = {value: key for key, value in d1.items()}
print(d2)