Python - Adding a individual value to multiple strings in text file wich end with consecutive numbers -


i have little trouble working out problem because iam using for-loop now.

i want edit text file:

indicate somename x1 random qwerty indicate somename x2 random azerty indicate somename x3 random qwertz indicate somename x4 random asdfg indicate somename x5 

here python script i'm running:

#for in range (0,4): open('text.txt') fp, open('text2.txt', 'w') fo:     line in fp:         number = 10           if ('indicate somename') in line:             in range (0,4):                 string = str(i)                 if (string) in line:                     print (string)                     content = line.strip() + " value = " '%d' % (number)                  else:                     content = line.strip()          else:             content = line.strip()         fo.write(content + "\n") 

well... problem continues rewriting principal in here. re-writes original time. need original file is.

this becomes output:

indicate somename x1 random qwerty indicate somename x2 random azerty indicate somename x3 value = 10 random qwertz indicate somename x4 random asdfg indicate somename x5 

the loops works 0-4, stop number 3.

does has solution problem? tried quite few things in results een worse this.

the value going different every time, because of for-loop function.


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -