Issue
I am new in Python.. But i realy confused with this problem...
The Print Results of the last 3 lines :
['John', 'Philiph', 'Derek', 'Melanie', 'Romy', 'Andy', 44]
[1, 2, 3, 4, 5, 6, 'John', 'Philiph', 'Derek', 'Melanie', 'Romy', 'Andy']
[[1, 2, 3, 4, 5, 6], ['John', 'Philiph', 'Derek', 'Melanie', 'Romy', 'Andy', 44]]
**QUESTION : ** 44 is in the t BUT---> WHY 44 isn't in the x
CODE :
z=[1,2,3,4,5,6]
h=['John', 'Philiph', 'Derek', 'Melanie', 'Romy', 'Andy']
x=z+h
t=[z,h]
#print(x)
#print(t)
h.append(44)
print(h)
print(x)
print(t)
Solution
z+h will create a single list containing h and z values meanwhile the [z,h] create a list of the two lists h and z
Answered By - Khalil Rebhi Answer Checked By - Katrina (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.