[Solved] How to get a list in below format? [closed]
Use strip and split as below to get the value separated as you want. file = open(‘file.txt’) my_arr = [] for line in file: fields = line.strip().split() my_arr.append([fields[0], “https://stackoverflow.com/”, fields[1][1:]]) print(my_arr) Output: [[‘22882367’, “https://stackoverflow.com/”, ‘pgc-orc-hive-output’], [‘13454914’, “https://stackoverflow.com/”, ‘pqs’], [‘2254110952’, “https://stackoverflow.com/”, ‘processed-nrt-export’]] 3 solved How to get a list in below format? [closed]