Skip to content

Commit aae53e5

Browse files
authored
List and Tuple
1 parent bd87bc7 commit aae53e5

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

List_AppCode.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
def main():
2+
names = []
3+
4+
# Append names to the list
5+
names.append("Robin")
6+
names.append("Aman")
7+
names.append("Rahul")
8+
9+
print(names)
10+
return 0
11+
12+
if __name__ == '__main__':
13+
main()

Tuple_String.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#change value at index 0 of both tuple to string "number"
2+
def main():
3+
tuple1 = tuple(("one", "two", "three"))
4+
tuple2 = tuple(("1", "2", "3"))
5+
6+
# Convert tuples to lists
7+
list1 = list(tuple1)
8+
list2 = list(tuple2)
9+
10+
# Modify values at index 0
11+
list1[0] = "number"
12+
list2[0] = "number"
13+
14+
# Convert lists back to tuples
15+
tuple1 = tuple(list1)
16+
tuple2 = tuple(list2)
17+
18+
print(tuple1)
19+
print(tuple2)
20+
21+
return 0
22+
23+
if __name__ == '__main__':
24+
main()

0 commit comments

Comments
 (0)