-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconcatenatingTuples.py
More file actions
35 lines (27 loc) · 910 Bytes
/
concatenatingTuples.py
File metadata and controls
35 lines (27 loc) · 910 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#Hack to declare empty lists with a pre-defined size
twoTables = [None] * 4
threeTables = [None] * 4
for i in range(0,4):
twoTables[i] = 2 * i;
threeTables[i] = 3*i;
print(twoTables)
print(threeTables)
#Now lets concatenate the two lists
twothreeTables = twoTables + threeTables;
print(twothreeTables)
#Now, lets do the same for lists
# tenTableTuple = [None] * 5
# eleventableTuple = [None] * 5
#converting list into a tuple
# tenTableTuple = tuple(tenTableTuple)
# eleventableTuple = tuple(eleventableTuple)
# for i in range(0,5):
# tenTableTuple[i] = 10 * i;
# eleventableTuple[i] = 11 * i;
#Cant do this because python doesnt support tuple item assignment
#So lets do it other way
twoTableTuple = tuple(twoTables) #convert a list onto tuple
threeTableTuple = tuple(threeTables)
#concatenation of tuples
twothreeTableTuple = twoTableTuple + threeTableTuple
print(twothreeTableTuple)