if a is [1,2,3], what is the meaning of a [1:2]=4 and a [1:1]=4
Answers
Answered by
1
Answer:
njsndnn answer 1
ajhzhshz answer 2
Answered by
6
a=[1,2,3]
'a' here is a list.
It is mutable.
1) If a=[1,2,3]
If we will run a[1:2]=[4]
Then 'a' will become [1,4,3]
i.e, a=[1,2,3]
a[1:2]=[4]
After this operation a=[1,4,3]
2) If a=[1,2,3]
If we will run a[1:1]=[4]
Then 'a' will become [1,4,2,3]
i.e, a=[1,2,3]
a[1:1]=[4]
After this operation a=[1,4,2,3]
Additional Information :
Lists :
- Ordered collection of data
- Are similar to string
- Way of creating the list : enclose the elements in square brackets []
- Eg1: l = [10,20,30,40]
- Eg2: l = ["hello",2.0,5,[10,20]]
Similar questions