I am having strings like:
"What is var + var?"
"Find the midpoint between (var,var) and (var,var)"
I want to change the each occurrence of var
s in the above sentences to the random different integers. My current code code is:
question = question.replace("var",str(random.randint(-10,10)))
This only made all the integers into the same randomly genererated number, For example;
"Find the midpoint between (5,5) and (5,5)"
As I'm aware that for
loops cannot be used on a string, how is it possible to change the substring "var" to different values rather than that single generated number?