Python Forum
looking for list help - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: looking for list help (/thread-36648.html)



looking for list help - tsathvik - Mar-14-2022

Here is the program which I was trying to write but I was not getting output as expected.

Program: ask user to take two inputs first input as list with three elements and other input as one integer and then append it and print as a list. we can use list.append() method but still not getting as expected.

ex: user provides below inputs
[1, 2, 3]
4

expected output: [1, 2, 3, 4]

but I was getting output ['[1, 2, 3]' , 4 ]


RE: looking for list help - Yoriz - Mar-14-2022

items = [1, 2, 3]
items.append(4)
print(items)
Output:
[1, 2, 3, 4]