+ 1

I don't understand the reason behind this output?

>>>My_list=[1,2,3,4] >>>My_list*-1 >>>[]

14th Jul 2019, 2:29 PM
parag sahu
parag sahu - avatar
6 Respostas
+ 4
There is no reason to multiplicate dictionaries, because each key in dictionary is supposed to be unique.
14th Jul 2019, 3:56 PM
Seb TheS
Seb TheS - avatar
+ 2
Ohh. So this is the logic. Thnx Dhanush Adithya
14th Jul 2019, 2:47 PM
parag sahu
parag sahu - avatar
+ 1
If you multiply a list with a positive number it'll multiply a list to n times >>>My_list=[1,2,3,4] >>>My_list*2 >>>[1,2,3,4,1,2,3,4] And if you multiply a list with a number < 1it'll clear the list >>> My_list=[1,2,3,4] >>>My_list*0 >>>[]
14th Jul 2019, 2:45 PM
deeyae
deeyae - avatar
+ 1
parag sahu Your welcome
14th Jul 2019, 2:47 PM
deeyae
deeyae - avatar
+ 1
That means it will work same for dictionary , tuples also ? Dhanush Adithya
14th Jul 2019, 2:47 PM
parag sahu
parag sahu - avatar
+ 1
parag sahu It works fine with List and Tuple but not with dict
14th Jul 2019, 2:54 PM
deeyae
deeyae - avatar