Split String into List using split() :
a = "Hello, World!"
print(a.split(","))
Output :
['Hello', ' World!']
Dictionary Length :
thisdict = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
print(len(thisdict))
Output :
3
Dictionary with Various Data Types :
thisdict = {
"brand": "Ford",
"electric": False,
"year": 1964,
"colors": ["red", "white", "blue"]
}
Print Dictionary Type :
thisdict = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
print(type(thisdict))
Output :
<class 'dict'>
Access Dictionary Item Using Key :
thisdict = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
x = thisdict["model"]
print(x)
Output :
Mustang
Access Dictionary Item Using get() :
x = thisdict.get("model")
print(x)
Output :
Mustang