[Solved] Print lists in list

Not sure what you mean with “store the data of ‘li1’ into an index”. I’m assuming you want a list of lists? You could append the list. k = “/BTC” result_list = [] for i in range(l): if k in dat1[“Data”][i][‘Label’]: value = dat1[“Data”][i][‘Label’] value1 = dat1[“Data”][i][‘TradePairId’] value2 = dat1[“Data”][i][‘AskPrice’] value3 = dat1[“Data”][i][‘BidPrice’] result_list.append([value, value1, … Read more

[Solved] Process each element in a list for each line from a text file [closed]

You need to split each string into each port, then print each one. And you can use enumerate() to get the line number. # Example data port_strings = [ ‘443, 9993’, ‘443, 3389, 445’, ‘443, 22, 3389, 23’, ‘3389, 445, 443’, ‘443, 3389, 445’] for i, port_string in enumerate(port_strings, 1): print(‘line’, i) for port in … Read more

[Solved] How to compare a nested list of Dicts to another nested list of Dicts and update the values in one from the other

I may have been massively over complicating things here, this appears to do what I want (ignoring the insertion of completely new markets / selection_id’s for now): new_order_list = [] for x in updated_orders: for y in x[‘Live_orders’]: orders_to_update = {} orders_to_update.update({‘Market_id’: x[‘Market_id’], ‘Selection_id’: y[‘selection_id’], ‘live_orders’: y[‘live_orders’]}) new_order_list.append(orders_to_update) for z in new_order_list: for a in … Read more

[Solved] TypeError: cannot concatenate ‘str’ and ‘list’ objects. how to convert list to string [closed]

str(tuple(str(fv[“v”]).split(‘,’))) will probably give you what you want but if you give more information there is definitely a better way to write this. What does fv[‘v’] consist of? 2 solved TypeError: cannot concatenate ‘str’ and ‘list’ objects. how to convert list to string [closed]

[Solved] Given a list of named doubles, return the name of the variable with the lowest value [closed]

You need a way to associate the inventory level of the ingredients (which you have as your double variables), with the order id of the ingredient (which is the result you want at the end). One solution would be to use an Ingredient class that might look something like this: public class Ingredient { public … Read more

[Solved] what is arr = [int(arr_temp) for arr_temp in input().strip().split(‘ ‘)] in python

You may want to look into python’s list comprehension. arr = [int(arr_temp) for arr_temp in input().strip().split(‘ ‘)] Let me answer this with an example, suppose you input : 1 3 4 29 12 -2 0 the input function reads this as a string The strip function eliminates whitespace from both ends of the string, The … Read more

[Solved] List elements to equal zero after 0 element

to add another options to all these good answers, another one with lambda: l = [4,3,3,2,1,0,1,2] f= lambda x,i : 0 if 0 in x[:i] else x[i] [f(l,i) for i in range(len(l))] output: [4, 3, 3, 2, 1, 0, 0, 0] 1 solved List elements to equal zero after 0 element

[Solved] How to sort a list and put it in absolute value

You can use the map and abs functions to accomplish this: In [1]: sorted(map(abs, lista)) Out[1]: [1, 2, 3, 5, 7, 8] To do this with the code you wrote, you can # The list defined above lista = [a,b,c,d] # Sorted from least to greatest absolute value sorted_abs_list = sorted(map(abs, lista)) # Sorted from … Read more