Python Forum
Arrange list of tuple using loop
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Arrange list of tuple using loop
#2
Hi,

first of all: your post would be _much_ more readable if you would write words correctly in upper and lower case and especially would use punctuation.

in Python you can iterate directly over list and tuples, as the are iterable. So no need for range or len or anything. Just do for item in iterable:.

I do not really understand what the final output should be. You a list of three tuples and want to get ... what? The example in your 2nd code block doesn't make to much sense... Do you want a dict for each item in the list, which would be three dicts as per your example. Or do you want to get a dict of dicts?
And why to do need a dict at all? Your input, the list of tuples, is already ordered, isn't it?
And did you check the documentation of your data source if this isn't able already to provide a dict instead of a list?

Regards, noisefloor
Reply


Messages In This Thread
Arrange list of tuple using loop - by batchenr - Jun-16-2019, 08:05 AM
RE: Arrange list of tuple using loop - by noisefloor - Jun-16-2019, 10:05 AM
RE: Arrange list of tuple using loop - by batchenr - Jun-16-2019, 10:27 AM
RE: Arrange list of tuple using loop - by DeaD_EyE - Jun-16-2019, 11:19 AM
RE: Arrange list of tuple using loop - by batchenr - Jun-16-2019, 02:37 PM
RE: Arrange list of tuple using loop - by Yoriz - Jun-16-2019, 03:03 PM
RE: Arrange list of tuple using loop - by Abdullah - Jun-16-2019, 03:24 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  using > < for tuple , list,... akbarza 3 580 Feb-05-2024, 01:18 PM
Last Post: deanhystad
Question mypy unable to analyse types of tuple elements in a list comprehension tomciodev 1 558 Oct-17-2023, 09:46 AM
Last Post: tomciodev
  Change font in a list or tuple apffal 4 2,798 Jun-16-2023, 02:55 AM
Last Post: schriftartenio
  search a list or tuple for a specific type ot class Skaperen 8 2,063 Jul-22-2022, 10:29 PM
Last Post: Skaperen
  why is my list a tuple CompleteNewb 7 2,363 Mar-17-2022, 10:09 PM
Last Post: CompleteNewb
  in a list or tuple Skaperen 6 111,181 May-16-2021, 09:59 PM
Last Post: Skaperen
  Create SQLite columns from a list or tuple? snakes 6 8,983 May-04-2021, 12:06 PM
Last Post: snakes
  What type of *data* is the name of a list/tuple/dict, etc? alloydog 9 4,547 Jan-30-2021, 07:11 AM
Last Post: alloydog
  code with no tuple gets : IndexError: tuple index out of range Aggam 4 2,963 Nov-04-2020, 11:26 AM
Last Post: Aggam
  Appending to list of list in For loop nico_mnbl 2 2,419 Sep-25-2020, 04:09 PM
Last Post: nico_mnbl

Forum Jump:

User Panel Messages

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