“Wörterbücher in Python” Code-Antworten

Wörterbuch in Python

Polygon = {
	"PolygonName" : "Tetrahectaseptadecagon"
	"PolygonSides" : 417
}

print("A", (Polygon["PolygonName"]) "has", (Polygon["PolygonSides"]), "sides")
Rick Astley

Python Dict

# A dict (dictionary) is a data type that store keys/values

myDict = {"name" : "bob", "language" : "python"}
print(myDict["name"])

# Dictionaries can also be multi-line
otherDict {
	"name" : "bob",
    "phone" : "999-999-999-9999"
}
codingiscool

Wörterbuch in Python

myDict = {
    "Fast": "In a Quick Manner",
    "Hasya": "A Coder",
    "Marks": [1, 2, 5],
    "anotherdict": {'hasya': 'Player'}
}

# print(myDict['Fast'])
# print(myDict['Hasya'])
myDict['Marks'] = [45, 78]
print(myDict['Marks'])
print(myDict['anotherdict']['hasya'])
Coding boy Hasya

Python Dict

mydictionary = {'name':'python', 'category':'programming', 'topic':'examples'}

for x in mydictionary:
	print(x, ':', mydictionary[x])
David Cao

Wörterbuch in Python

#a dictionary
dict = {
  "key": "value",
  "other_key": "value"
}

#get a value from the dictionary using the key
print(dict["key"])

#you can also get a value from the dictionary using a normal index:
print(dict[1])
Poor Pony

Wörterbücher in Python

# Creating a Nested Dictionary
# as shown in the below image
Dict = {1: 'Geeks', 2: 'For',
        3:{'A' : 'Welcome', 'B' : 'To', 'C' : 'Geeks'}}
 
print(Dict)
Exuberant Eland

Ähnliche Antworten wie “Wörterbücher in Python”

Fragen ähnlich wie “Wörterbücher in Python”

Weitere verwandte Antworten zu “Wörterbücher in Python” auf Python

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen