A tuple with two integers,
A tuple with two strings,
A tuple with only one element,
Hint: you can either use the syntax presented at the beginning of the chapter, or use a list-tuple conversion.
A tuple with the integers between 0 and 99.
Hint: is there some way to exploit the
l = [0, 1, 2]and
t = (0, 1, 2), what is the difference between:
x = l x = "ok"
x = t x = "ok"
Given the tuple:
tup = (0, 1, 2, [3, 4, 5], 6, 7, 8)
- What is the type of the first element of the tuple?
- What is the type of the fourth element?
- How many elements does the tuple contain?
- How many elements does the inner list contain?
- Change the last element of the inner list to
- Change the last element of the tuple to
"very last element". (Can you do that without resorting to tricks?)