Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Access list items in Python

How can I access the values of A1, A2 and A3?

Is this a dictionary inside of a list?

>>> type(data)
<class 'list'>
>>> pprint(data)
[{'A1': 'BCN',
  'A2': 'To Offer jobs',
  'A3': 'yes',
  'Date Added': 'Dec 31, 2019',
  'Facebook User Name': 'Julian Pedersen',
  'First Name': 'Julian',
  'Group Name': 'Barcelona Events',
  'Joined': 'Jun 9, 2008',
  'Last Name': 'Pedersen',
  'User ID': 107345707},
 {'A1': 'barcelona',
  'A2': 'To meet people',
  'A3': 'no',
  'Date Added': 'Dec 31, 2019',
  'Facebook User Name': 'Tania Timush',
  'First Name': 'Tania',
  'Group Name': 'Barcelona Events',
  'Joined': 'Nov 27, 2017',
  'Last Name': 'Timush',
  'User ID': 100023456973042}]
sorry, but you ask virtually the same question without trying to understand the solution offered and implement it yourself for this use case.
data is list of dicts. iterate over the elements in the list, then for each element (a dict) access the values you want.
I think I got it...

for words in data:

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Add items from one list to list of lists PUP280 2 285 Mar-28-2020, 08:34 AM
Last Post: PUP280
  Can't seem to figure out how to put all of the lists items from a loop into 1 list Cosmosso 4 353 Feb-21-2020, 02:40 PM
Last Post: Cosmosso
  Python for MS Access DB Kundan 0 126 Feb-20-2020, 08:27 AM
Last Post: Kundan
  counting items in a list of number combinations Dixon 2 129 Feb-19-2020, 07:06 PM
Last Post: Dixon
  List items verification for Integer type vintysaw 4 214 Jan-17-2020, 01:56 PM
Last Post: perfringo
  Remove all \n from end of list items JackMack118 4 7,672 Dec-27-2019, 08:34 AM
Last Post: perfringo
  Removing duplicate list items eglaud 4 236 Nov-22-2019, 08:07 PM
Last Post: ichabod801
  Adding items in a list (using loops?) Seneca260 6 353 Nov-22-2019, 11:34 AM
Last Post: Seneca260
  removing items from a list or group within a for loop. allusernametaken 9 439 Nov-13-2019, 01:58 AM
Last Post: allusernametaken
  Replace Items in List. mcmxl22 3 345 Oct-07-2019, 05:05 AM
Last Post: Larz60+

Forum Jump:

Users browsing this thread: 1 Guest(s)