How to change the range of item in Python
A range of item in list is one of the most important part in programming when you want to change an item. Here is the basic to use that code in Python for How to change the range of item in list of Python it is as simple as other programming.
The length of list will change according to the item that we have in list.
myCar=['Toyota', 'Mitsubishi','Volvo']
myCar[1]='Honda'
print(myCar)
#output: ['Toyota', 'Honda', 'Volvo']
For example 2:
myCar=['Toyota', 'Mitsubishi','Volvo']
myCar[1:3]='Honda','BMW'
print(myCar)
#output: ['Toyota', 'Honda', 'BMW']
We can use insert method to replace the existing item index in list. So the existing item which stay on the current position that we want to insert into, will be move to the next position.
For example 3:
myCar=['Toyota', 'Mitsubishi','Volvo']
myCar.insert(2,'Honda')
print(myCar)
#output: ['Toyota', 'Mitsubishi', 'Honda', 'Volvo']