0
I have a text document with the following format:
word_1 word_2 word_3
word_4 word_5 word_6
For each line of that text document:
- first: I want to save the words and add "_info" to each word;
second: the arguments I want to use in the next function (which repeats for each line) are:
def my_function ("word_1","word_2","word_3","word_1_info","word_2_info","word_3_info")
After the first calculations with the arguments of the first line, the following arguments will be:
def my_function ("word_4","word_5","word_6","word_4_info","word_5_info","word_6_info")
The closest I’ve been was reading (because I’m having trouble adding "_info" to each word), the information from the text file as follows:
f = open("test.txt","r")
array=[]
for line in f:
x = re.findall(r"[a-zA-Z]+_+\d",line)
array.append(x)
def my_function("array[0][0]","array[0][1]","array[0][2]")
How can I improve my code to do what I need?