Python Forum
Converting List into list of tuples
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Converting List into list of tuples
#3
If you go with zip(), you'll want to slice the list up into lowercase an uppercase characters to get the desired result.

my_list = ['a', 'A', 'b', 'B', 'c', 'C']
for pair in zip(my_list[::2], my_list[1::2]):
    print(pair)
Reply


Messages In This Thread
Converting List into list of tuples - by ARV - Sep-27-2019, 05:40 PM
RE: Converting List into list of tuples - by stullis - Sep-27-2019, 09:12 PM
RE: Converting List into list of tuples - by adt - Sep-28-2019, 03:37 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Strange behavior list of list mmhmjanssen 2 192 May-01-2024, 07:16 AM
Last Post: Gribouillis
  No matter what I do I get back "List indices must be integers or slices, not list" Radical 4 1,227 Sep-24-2023, 05:03 AM
Last Post: deanhystad
  Delete strings from a list to create a new only number list Dvdscot 8 1,582 May-01-2023, 09:06 PM
Last Post: deanhystad
  List all possibilities of a nested-list by flattened lists sparkt 1 945 Feb-23-2023, 02:21 PM
Last Post: sparkt
  Adding values with reduce() function from the list of tuples kinimod 10 2,742 Jan-24-2023, 08:22 AM
Last Post: perfringo
  Сheck if an element from a list is in another list that contains a namedtuple elnk 8 1,881 Oct-26-2022, 04:03 PM
Last Post: deanhystad
Question Keyword to build list from list of objects? pfdjhfuys 3 1,603 Aug-06-2022, 11:39 PM
Last Post: Pedroski55
  Split a number to list and list sum must be number sunny9495 5 2,338 Apr-28-2022, 09:32 AM
Last Post: Dexty
  How to check if a list is in another list finndude 4 1,866 Jan-17-2022, 05:04 PM
Last Post: bowlofred
  Different out when using conda list and pip list Led_Zeppelin 1 4,081 Jan-14-2022, 09:30 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

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