Python Forum
What type of *data* is the name of a list/tuple/dict, etc?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What type of *data* is the name of a list/tuple/dict, etc?
#7
(Jan-13-2021, 08:18 PM)buran Wrote:
for idx, device in enumerate(devices, start=1):
    print(f'{idx: >2d}.{device.part_no}')
user_choice = int(input(f'Select device (1-{len(devices)}): ')) - 1

I'm going through the various replies and solutions bit by bit (I want understand what each bit does, rather than just copy/paste and say "yee ha!" it works...)

From the namedtuple solution from @buran - I pretty much get what each bit does, except >2d. I even removed : >2d from the script, ran it and it worked pretty much the same.

What does the : >2d bit do?
Reply


Messages In This Thread
RE: What type of *data* is the name of a list/tuple/dict, etc? - by alloydog - Jan-28-2021, 05:01 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Help with to check an Input list data with a data read from an external source sacharyya 3 522 Mar-09-2024, 12:33 PM
Last Post: Pedroski55
  using > < for tuple , list,... akbarza 3 550 Feb-05-2024, 01:18 PM
Last Post: deanhystad
Question mypy unable to analyse types of tuple elements in a list comprehension tomciodev 1 533 Oct-17-2023, 09:46 AM
Last Post: tomciodev
  Change font in a list or tuple apffal 4 2,767 Jun-16-2023, 02:55 AM
Last Post: schriftartenio
  search in dict inside tuple steg 1 737 Mar-29-2023, 01:15 PM
Last Post: rob101
  search a list or tuple for a specific type ot class Skaperen 8 2,029 Jul-22-2022, 10:29 PM
Last Post: Skaperen
  TypeError: unsupported operand type(s) for +: 'dict' and 'int' nick12341234 1 9,456 Jul-15-2022, 04:04 AM
Last Post: ndc85430
  Membership test for an element in a list that is a dict value for a particular key? Mark17 2 1,271 Jul-01-2022, 10:52 PM
Last Post: Pedroski55
  Are list/dict comprehensions interpreted really sequentially? anata2047 3 1,505 May-31-2022, 08:43 PM
Last Post: Gribouillis
  TypeError: unsupported opperand type(s) for %: 'int' and 'list' cool_person 7 2,284 May-07-2022, 08:40 AM
Last Post: ibreeden

Forum Jump:

User Panel Messages

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