Python Forum
converting the items of a list in new lists
Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
converting the items of a list in new lists
#1
Good morning friends,
I have the list1 (in a simplified way) that I need to convert to the list2. I can't find the way.
Could you help me, please?

list1 = ['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday']


list2 = [[Monday],[Tuesday],[Wednesday],[Thursday],[Friday],[Saturday],[Sunday]]
Reply
#2
list2 = [[weekday] for weekday in list1]
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
It seems so easy this way...
Thank you very much!!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Why do I have to repeat items in list slices in order to make this work? Pythonica 7 2,923 May-22-2023, 10:39 PM
Last Post: ICanIBB
  List all possibilities of a nested-list by flattened lists sparkt 1 1,796 Feb-23-2023, 02:21 PM
Last Post: sparkt
  Finding combinations of list of items (30 or so) LynnS 1 1,535 Jan-25-2023, 02:57 PM
Last Post: deanhystad
  user input values into list of lists tauros73 3 1,993 Dec-29-2022, 05:54 PM
Last Post: deanhystad
  returning a List of Lists nafshar 3 1,982 Oct-28-2022, 06:28 PM
Last Post: deanhystad
  Creating list of lists, with objects from lists sgrinderud 7 3,104 Oct-01-2022, 07:15 PM
Last Post: Skaperen
  For Word, Count in List (Counts.Items()) new_coder_231013 6 6,918 Jul-21-2022, 02:51 PM
Last Post: new_coder_231013
  How to get list of exactly 10 items? Mark17 1 3,693 May-26-2022, 01:37 PM
Last Post: Mark17
  how to assign items from a list to a dictionary CompleteNewb 3 2,722 Mar-19-2022, 01:25 AM
Last Post: deanhystad
  Reading list items without brackets and quotes jesse68 6 6,894 Jan-14-2022, 07:07 PM
Last Post: jesse68

Forum Jump:

User Panel Messages

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