- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtuple.py
More file actions
Latest commit
executable file
·24 lines (16 loc) · 658 Bytes
/
Copy pathtuple.py
File metadata and controls
executable file
·24 lines (16 loc) · 658 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
""" this program is for the demonstration of tuples in python """
""" this also demonstrates convertig tuples to a list, check if tuple exists and so on.... """
mytuple= ("hello","hi","tuple","bye")
# tuples ar immutable that is they cannot be modified no adding of items no removing of items
# it is like a static list
forxinmytuple:
print(x)
""" workaround for adding items to a tuple """
y=list(mytuple)
y.append("workaround")
mytuple=tuple(y)
forxinmytuple:
print(x)
# creating tuple with a single element
newtuple= ("new",) # we have to insert that comma otherwise python would not understand it as a tuple
print(newtuple)