0

When i did number =3 and list=[string,0,[1+2+number],4.2] and print ([2]*[2]) then why there was an error

It was the programm of python in topic of string. number = 3 things = ["string", 0, [1+ 2+ number], 4.56] print(things[1]) print(things[2]) print(things[2]*[2])

20th Apr 2019, 7:02 AM
saood khan
saood khan - avatar
4 odpowiedzi
+ 2
You can't multiply two lists. print(things[2]) # [6] (list with one element) print(things[2][0]*[2][0]) # = 6*6
20th Apr 2019, 7:35 AM
Anna
Anna - avatar
+ 1
Makes sure the second argument is also things[2] and not just [2]
20th Apr 2019, 7:08 AM
Bram
0
I did not get, actually i have edited code and multiply [2]*[2] and i have changed [1,2,number] to [1+2+number].
20th Apr 2019, 7:21 AM
saood khan
saood khan - avatar
0
Thank u verry much i got it may allah bless u
20th Apr 2019, 9:23 AM
saood khan
saood khan - avatar