Q. Write a Python program to append a list to the second list.
Answer =
lst1 = eval(input("Enter Frist list :-")) lst2 = eval(input("Enter Second list :-")) lst1 += lst2 print(lst1)
Output :-
Enter Frist list :-[ 1,2,3,4]
Enter Second list :-[5,6,7,8,9]
[1, 2, 3, 4, 5, 6, 7, 8, 9]
>>>
Enter Second list :-[5,6,7,8,9]
[1, 2, 3, 4, 5, 6, 7, 8, 9]
>>>
Enter Frist list :-["Path", "Walla", "Portal", ""]
Enter Second list :-["Express", "Python"]
['Path', 'Walla', 'Portal', '', 'Express', 'Python']
>>>
Enter Second list :-["Express", "Python"]
['Path', 'Walla', 'Portal', '', 'Express', 'Python']
>>>
this is not working. showing "tuple not attributed to append"
ReplyDeleteI think you have input Tuple but question want that user must enter List.
DeleteWhere is output
ReplyDeleteOk,
DeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )