[Tutor] reg. list update
Rasika Sapate
cs16mtech11014 at iith.ac.in
Mon Apr 17 14:41:29 EDT 2017
Dear Python group,
I had written following code.
super = []
sub = [""]*3
other = ["a","b","c","d"]
sub[0] = "hi"
sub[1] = "hello"
for item in other:
sub[2] = item
super.append(sub)
for item in super:
print item
Output :
['hi', 'hello', 'd']
['hi', 'hello', 'd']
['hi', 'hello', 'd']
['hi', 'hello', 'd']
Expected output:
['hi', 'hello', 'a]
['hi', 'hello', 'b']
['hi', 'hello', 'c']
['hi', 'hello', 'd']
Is there anything wrong in this code or any feature of python?
Thanks and regards,
Rasika Sapate.
More information about the Tutor
mailing list