Python Forum
Appending to a List in Python 3
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Appending to a List in Python 3
#3
Not sure if I understand. Tried the following but it did not work. Sorry still new to python.
my_list = [2,3,4,5]
lst = []
sub_lst = []
for i in my_list:
  sub_lst.append(i)
  for j in range(0,4):
    lst.append(sub_lst)
print(lst)
Reply


Messages In This Thread
Appending to a List in Python 3 - by kas_samrari - Nov-30-2018, 06:59 PM
RE: Appending to a List in Python 3 - by ichabod801 - Nov-30-2018, 07:03 PM
RE: Appending to a List in Python 3 - by kas_samrari - Nov-30-2018, 07:27 PM
RE: Appending to a List in Python 3 - by ichabod801 - Nov-30-2018, 08:04 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Time.sleep: stop appending item to the list if time is early quest 0 1,912 Apr-13-2021, 11:44 AM
Last Post: quest
  Reading and appending list MrSwiss 1 1,788 Mar-01-2021, 09:01 AM
Last Post: Serafim
  Appending list Trouble Big Time Milfredo 7 3,251 Oct-01-2020, 02:59 AM
Last Post: Milfredo
  Appending to list of list in For loop nico_mnbl 2 2,418 Sep-25-2020, 04:09 PM
Last Post: nico_mnbl
  appending list of list glennford49 2 2,217 Mar-29-2020, 09:33 AM
Last Post: ibreeden
  Appending to list not working and causing a infinite loop eiger23 8 4,108 Oct-10-2019, 03:41 PM
Last Post: eiger23
  Appending a list in a class from a callback function snizbatch 5 3,843 Sep-01-2019, 06:27 AM
Last Post: snizbatch
  appending list items to other lists clarablanes 4 2,916 Dec-08-2018, 02:15 PM
Last Post: clarablanes
  trouble while appending list in for loop py_learner 1 2,891 May-28-2018, 01:55 AM
Last Post: scidam
  Unexpected behavior appending to a List of Dictionaries Nomad 2 2,816 Apr-03-2018, 04:22 AM
Last Post: Nomad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020