Computer Science
What's a[1 : 1] if a is a list of at least two elements? And what if the list is shorter?
Related Questions
If a is [1, 2, 3]
- what is the difference (if any) between a * 3 and [a, a, a]?
- is a * 3 equivalent to a + a + a?
- what is the meaning of a[1:1] = 9?
- what's the difference between a[1:2] = 4 and a[1:1] = 4?
How are the statements lst += "xy" and lst = lst + "xy" different, where lst is a list? Explain.
How are the statements lst = lst + 3 and lst += [3] different, where lst is a list? Explain.
Start with the list [8, 9, 10]. Do the following using list functions:
- Set the second entry (index 1) to 17
- Add 4, 5 and 6 to the end of the list
- Remove the first entry from the list
- Sort the list
- Double the list
- Insert 25 at index 3