Define a List in Python. Explain any five operations that can be performed in List with example.
Answers
Answered by
1
Answer:
indexing
my_list = ['p', 'r', 'o', 'b', 'e']
# Output: p
print(my_list[0])
# Output: o
print(my_list[2])
# Output: e
print(my_list[4])
# Nested List
n_list = ["Happy", [2, 0, 1, 5]]
# Nested indexing
print(n_list[0][1])
print(n_list[1][3])
# Error! Only integer can be used for indexing
print(my_list[4.0])
Output
p
o
e
a
5
Similar questions
Social Sciences,
4 months ago
Science,
4 months ago
English,
4 months ago
Math,
8 months ago
Hindi,
1 year ago
Social Sciences,
1 year ago
Chinese,
1 year ago