Tuesday, June 17, 2014

dictionary vs tuple

One of the main differency between dictionary and tuple is 'tuple' indices must be integers and 'tuple' object does not support item assignment.


dictionary = {"day0": "sday", "day1": "Monday"}
print(dictionary["day0"])
dictionary["day0"] = "Sunday"
print(dictionary["day0"])

#tuple indices must be integers
tuple = ("sday", "Monday")
print(tuple[0])
#'tuple' object does not support item assignment
#tuple[0] = "Sunday"