0

explain this code briefly

list by=[1,2,3,4,5,6,7,8,9] del list py [-3: -6: -1] print (list_py)

9th Apr 2020, 11:47 AM
Arshad Shaik
Arshad Shaik - avatar
3 Answers
+ 1
it is a bit chaotic list by list py list_py is it all the same and simply typo?
9th Apr 2020, 12:05 PM
Oma Falk
Oma Falk - avatar
+ 1
The variable "list by" should be "list_by" or any alternative with no spaces. But is a list of numbers 1 through 9. You want to delete numbers in list (which should have same variable name as above) backwards through the list starting at 7 and down to but omitting 4. the argument in print needs the same variable name as the other two because thats the list you just worked on
9th Apr 2020, 12:06 PM
Slick
Slick - avatar
0
del list_py [-3:-6:-1] -3 = 7 -6 = 4(not inclusive stops at -5(5)) deletes [7,6,5] Output [1,2,3,4,8,9]
9th Apr 2020, 12:11 PM
Justus
Justus - avatar