+ 2
Why is i = [1,2,3,4]*(-1) turns out to be [ ]?
3 Respostas
+ 10
list * n will return a new list with the items of "list" repeated n times. So i*2 would be [1, 2, 3, 4, 1, 2, 3, 4].
list * (anything < 1) will return an empty list because the elements of the list are returned / repeated 0 times.
+ 3
you probably want:
[-n for n in i]
+ 1
Multiplying a list with a negative number returns an empty list. What else would you like to get?