I want to be able to replace the same set of string to random new unique numbers.
From:
color = { 0 0 0 }
To:
color = { 2 5 10 }
color = { 1 59 102 }
color = { 9 72 200 }
On each line of the text file.
Here's my python code.
import random
for i in range(0, 10):
x = str(random.randrange(0, 256))
y = str(random.randrange(0, 256))
z = str(random.randrange(0, 256))
with open("9.txt", "r") as file:
file_data = file.read()
file_data = file_data.replace("color = { 0 0 0 }", "color = { " + x + " " + y + " " + z + " }")
with open("colored.txt", "w") as file:
file.write(file_data)
This code changes all correctly but to the same values and I want it to be unique numbers.