-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTuples.py
More file actions
77 lines (29 loc) · 711 Bytes
/
Tuples.py
File metadata and controls
77 lines (29 loc) · 711 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env python
# coding: utf-8
# # Tuples are versy similar to list . However they have one key difference - immutability once an elemenet is indside in tuple , it can not be reassigned , tuple use parenthesis (1,2,3)
# In[1]:
my_tuple = (1,2,3)
# In[2]:
my_tuple
# In[3]:
type(my_tuple)
# In[4]:
my_list = [1,2,3]
# In[5]:
my_list
# In[6]:
type(my_list)
# In[9]:
# get value index
my_tuple.index(2)
# In[12]:
# count how many time value occured
my_tuple.count(2)
# In[14]:
# check immutabilty
my_list[1] = 'uzair'
my_list
# In[15]:
# but in tuple it will thorugh an error "'tuple' object does not support item assignment"
my_tuple[1] = 'uzair'
# In[ ]: