21 Working with Tuples
21.1 Task : Creating a Tuple
21.2 Task : Evaluating Tuple Items
21.3 Task : Counting Tuple Items
- File tuples.py
def mytuple(list, list2):
elements = []
for x in range(max(len(list),len(list2))):
if x < len(list):
elements.append(list[x])
if x < len(list2):
elements.append(list2[x])
return tuple(elements)
def mytuple2(list, list2):
return mytuple(list, list2)
def mytuplecount(elements):
dictionary = {}
for x in range(len(elements)):
dictionary[elements[x]] = elements.count(elements[x])
return dictionary