While listed in python

Asked

Viewed 691 times

-3

Could someone help with the following doubt?

in "item", the goal is to loop from 0 to 50

id_rec = [conteudo['complainResult']['complains']['data'][item]['id']] 

I made the following code:

item = 0
while item < len(id_rec):
        item = item + 1

However, you have only returned the first record. How to proceed?

1 answer

0

Probably the list id_rec has only one item...

When you have a list that belongs to another list, it only counts as an element... see the example:

>>> a = [1, 2, 3, 4]
>>> b = [a]

>>> len(a)
4
>>> len(b)
1
  • What would be the way, then?

  • It depends on what the content of id_rec is... Without knowing what you have you can’t help

  • the contents are being pulled from this JSON: https://iosearch.reclameaqui.com.br/raichu-io-site-search-v1/query/companyComplains/50/0?company=38653&status=ANSWERED&evaluated=bool:false

  • only returns 50 results at a time. The idea is to create the list with these 50 records (changing the item value), in a kind of "for". Got it?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.