Q:

remove random character from a dictionary python all items from dictionary python

#this only works for versions of python before 3.7

thisdict =	{
  "brand": "Ford",
  "model": "Mustang",
  "year": 1964
}
thisdict.popitem()
print(thisdict)
1
#the pop.item() method removes the last inserted item in Dictionary
#In python versions lower than 3.7 will remove a RANDOM ITEM

thisdict = {
  "brand": "Ford",
  "model": "Mustang",
  "year": 1964
}
thisdict.popitem()
print(thisdict)
1
# this only works with pyton version before 3.7

thisdict =	{
  "brand": "Ford",
  "model": "Mustang",
  "year": 1964
}
thisdict.popitem()
print(thisdict)
0

New to Communities?

Join the community