I just want to minify the rows of the code. I have two loops with the only difference two lines. Is it possible (functions or classes) to change the lines in each occasion? The two loops are:
cursor = ''
while True:
data = API_like_query(id,cursor)
#more code
for i in data['data']:
ids_likes += i['id']+' , '
#more code
and
cursor = ''
while True:
data = API_com_query(id,cursor)
#more code
for i in data['data']:
ids_likes += i['from']['id']+' , '
#more code
More code is the same chunk of code used. The difference is in the function call (line 3) and the different dictionary object in line 6.
ids_likesjust a string with IDs joined by ' , '? Then you should use' , '.join(lst)