I want to move part of the list to another list with a loop But I have problem
Something like that (But this code is bug)
mylist = [1,2,3,4,5,6,7,8]
i=[]
for i in mylist.append(range(1,5)) :
print(i)
I want the numbers 2 to 6 to be in i
Thanks to everyone I solved this problem With this code
mylist = [1, 2, 3, 4, 5, 6, 7, 8]
i = []
b=0
c=1
while b < 5 :
i.append(mylist[c])
print(i)
b+=1
c+=1