Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
YouTube Security VideosMicrosoft Mechanics: Teach Your Copilot Agent a Repeatable Skill(24.09.2026 um 03:45 Uhr)
Sichere ProgrammierungTrenches Developer(24.09.2026 um 03:36 Uhr)
Sichere ProgrammierungThe Hard Part of an API Isn't Calling It(24.09.2026 um 03:38 Uhr)
Sichere ProgrammierungWhy SVG exports look blurry: a practical PNG checklist(24.09.2026 um 03:39 Uhr)
Sichere ProgrammierungTDD for Requirements(24.09.2026 um 03:59 Uhr)
Linux Tipps & Hardening(real) Linux terminal(24.09.2026 um 03:58 Uhr)
YouTube Security VideosMicrosoft Mechanics: Teach Your Copilot Agent a Repeatable Skill(24.09.2026 um 03:45 Uhr)
Sichere ProgrammierungTrenches Developer(24.09.2026 um 03:36 Uhr)
Sichere ProgrammierungThe Hard Part of an API Isn't Calling It(24.09.2026 um 03:38 Uhr)
Sichere ProgrammierungWhy SVG exports look blurry: a practical PNG checklist(24.09.2026 um 03:39 Uhr)
Sichere ProgrammierungTDD for Requirements(24.09.2026 um 03:59 Uhr)
Linux Tipps & Hardening(real) Linux terminal(24.09.2026 um 03:58 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

Dictionaries: When a List Just Isn't Enough

You have a list of five numbers. person = ["Alex", 25, "Mumbai", True, "[email protected]"] Quick question. What is person[3]? You have to count. Index 0 is the name. Index 1 is age. Index 2 is city. Index 3 is... the boolean? What…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

You have a list of five numbers.




person = ["Alex", 25, "Mumbai", True, "[email protected]"]






Quick question. What is person[3]?



You have to count. Index 0 is the name. Index 1 is age. Index 2 is city. Index 3 is... the boolean? What does True mean here? Is that married? Is that a student? Is that something else entirely?



You wrote this code yourself and you already can't remember what index 3 means.



Now imagine coming back to this code three weeks later.






This is the exact problem dictionaries solve. Instead of accessing data by position, you access it by name. Instead of person[3] you write person["is_student"]. The name tells you everything.









What a Dictionary Looks Like



Curly braces. Key and value pairs separated by colons. Pairs separated by commas.




person = {
"name": "Alex",
"age": 25,
"city": "Mumbai",
"is_student": True,
"email": "[email protected]"
}






Now access any value by its key.




print(person["name"])
print(person["age"])
print(person["is_student"])






Output:




Alex
25
True






No counting. No guessing. person["age"] tells you exactly what you're getting.









Adding, Changing, Removing



A dictionary is not frozen after you create it. You can change it freely.




person = {"name": "Alex", "age": 25}

person["city"] = "Mumbai" # add new key
person["age"] = 26 # update existing key
del person["city"] # delete a key

print(person)






Output:




{'name': 'Alex', 'age': 26}






Assigning to a key that exists updates it. Assigning to a key that doesn't exist creates it. Clean and consistent.









The Safe Way to Get Values



What happens when you ask for a key that doesn't exist?




person = {"name": "Alex", "age": 25}
print(person["city"])









KeyError: 'city'






Your program crashes. Not ideal.



Use .get() instead. It returns None if the key doesn't exist instead of crashing.




city = person.get("city")
print(city) # None

city = person.get("city", "Unknown")
print(city) # Unknown






The second argument to .get() is a default value. If the key exists, you get the real value. If it doesn't, you get the default. Your program keeps running.



Use .get() whenever the key might not be there. Use person["key"] only when you're certain the key exists.









Looping Through a Dictionary



Three ways. Each one useful for different situations.




scores = {"Alex": 92, "Priya": 88, "Sam": 75, "Jordan": 95}

for key in scores:
print(key)






Output:




Alex
Priya
Sam
Jordan






Just the keys. Now both:




for key, value in scores.items():
print(f"{key}: {value}")






Output:




Alex: 92
Priya: 88
Sam: 75
Jordan: 95






.items() gives you each key-value pair as a tuple. The for key, value unpacks it. This is the one you'll use most.



Just the values if you need them:




for value in scores.values():
print(value)






Output:




92
88
75
95












Checking If a Key Exists



Before you access a key, sometimes you need to know if it's there.




person = {"name": "Alex", "age": 25}

if "city" in person:
print(person["city"])
else:
print("No city found")






Output:




No city found






in works with dictionaries just like with lists. Checks keys, not values.









Dictionaries Inside Lists



This is the pattern you will see constantly in real data work.




students = [
{"name": "Alex", "score": 92, "passed": True},
{"name": "Priya", "score": 58, "passed": False},
{"name": "Sam", "score": 75, "passed": True},
{"name": "Jordan", "score": 44, "passed": False}
]

for student in students:
if student["passed"]:
print(f"{student['name']} passed with {student['score']}")
else:
print(f"{student['name']} needs to retake the exam")






Output:




Alex passed with 92
Priya needs to retake the exam
Sam passed with 75
Jordan needs to retake the exam






A list of dictionaries. Every item in the list is a dictionary with the same keys. This is exactly how JSON data looks. This is how APIs return data. This is how database records get processed in Python.



Get comfortable with this shape. You'll work with it for the rest of your programming life.









Counting Things With a Dictionary



One classic use case. Count how many times each item appears.




words = ["python", "is", "fun", "python", "is", "great", "python"]

counts = {}

for word in words:
if word in counts:
counts[word] = counts[word] + 1
else:
counts[word] = 1

print(counts)






Output:




{'python': 3, 'is': 2, 'fun': 1, 'great': 1}






Walk through what happens. First time Python sees "python", it's not in counts yet. So counts["python"] = 1. Second time it sees "python", it IS in counts. So counts["python"] = counts["python"] + 1 which is 1 + 1 = 2. Third time, 2 + 1 = 3.



This exact pattern, counting occurrences, shows up in text analysis, data cleaning, building histograms, and more.









The One Thing That Catches Everyone



Dictionary keys must be unique. If you add the same key twice, the second value overwrites the first. Silently. No error.




data = {
"name": "Alex",
"age": 25,
"name": "Alexander" # duplicate key
}

print(data["name"])






Output:




Alexander






"Alex" is gone. "Alexander" replaced it without any warning. Python doesn't complain. This causes bugs that are genuinely hard to find because nothing crashes.



Double check your keys when creating a dictionary manually.









Dictionary vs List: When to Use Which



Use a list when order matters and you're dealing with a sequence of similar things. A list of names. A list of scores. A sequence of steps.



Use a dictionary when you want to label your data. A user profile. A config file. Anything where you need to look something up by name instead of by position.



In data science and AI, you'll use both constantly, often together. Models output dictionaries. Datasets are lists of dictionaries. Configuration is a dictionary. Results are stored in dictionaries.









Try This



Create dictionaries_practice.py.



Build a dictionary for a product in an online store. It should have at least six keys: name, price, category, in_stock (boolean), rating, and number of reviews.



Then write code that does all of this:



Print a nicely formatted product description using the values from your dictionary.



Add a "discount_percent" key with a value of 10.



Calculate and print the discounted price using the values already in the dictionary.



Write a loop that goes through the dictionary and prints every key and value on its own line.



Finally, try accessing a key that doesn't exist using .get() with a sensible default value.









What's Next



Lists and dictionaries store collections of data. But what if you want to create your own custom data type, something that bundles both data and behavior together? That's what classes and objects are for, and that's exactly where we're heading.

SOC Incident Playbook: Remote Code Execution (RCE) Defense
title: Detect Exploitation - Dictionaries: When a List Just Isn't Enough
id: 9e01f2ff-58d4-480e-8291-bd4b1c279513
status: experimental
description: Automatisch generierte SIEM-Erkennungsregel basierend auf CTI Intelligence
references:
  - https://tsecurity.de/
author: iShareStuff CTI Automated Detection Engine
date: 2026-09-24
logsource:
  category: network_connection
  product: any
detection:
  selection:
      CommandLine|contains:
        - 'exploit'
  condition: selection
falsepositives:
  - Legitime administrative Zugriffe oder Penetrationstests
level: high
tags:
  - attack.initial_access
rule CTI_Threat_Indicator {
    meta:
        author = "iShareStuff CTI Automated Detection Engine"
        date = "2026-09-24"
        description = "YARA Signature for "
    strings:
        $str = "Dictionaries: When a List Just" ascii wide
    condition:
        any of them
}
tsecurity.de Cognitive Threat RAG
Fokus-Vektor:

Kognitive Analyse für identifizierte Bedrohung: Erhöhte Bedrohungslage im Bereich Dictionaries: When a List Just Isn't Eno.... Basierend auf 368k Vektor-Korrelationen werden sofortige Isolationsmaßnahmen für betroffene Endpunkte empfohlen.

🛡️ Angriffsfläche & Exposure

Netzwerk/Remote-Zugriff ohne Vorauthentifizierung möglich.

Empfohlene Sofortmaßnahmen
  • 1. Perimeter-Inspektion: Relevante Portfreigaben und exponierte Endpunkte unverzüglich scannen.
  • 2. Patch-Applikation: Hersteller-Hotfix einspielen oder betroffene Daemons in isolierte DMZ-Segmente überführen.
  • 3. Telemetrie & EDR-Alerts: Prozessaufrufe und Child-Processes auf anomale Shell-Spawns überwachen.
🔗 Semantisch verwandte Zero-Days MariaDB 11.7 VEC
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Dictionaries: When a List Just Isn't Enough

Thematisch verwandte Begriffe: Dictionaries, When, List, Just · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-96676 | A vulnerability was identified in Fast FAC1900R 20190827_2.0.2. The impa…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel TTP ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick