I want to be able to change all values that meet the condition as one. This moment in time I do one value at the time. It might be more than one value that meet the condition, but it need to be change differently.
Let say value x and value y meet the condition and value x is change to x1 and value y to y1. What I'm trying to do is changing all appearance of value x at one time and all appearance of value y at one time
all_rows = []
for row in all_rows:
some_num = row[0]
if strformat.match(some_num):
continue
change = input(f"\n'{some_num}' doesn't match, change it to: ")
row[0] = change.strip()
CodePudding user response:
You could keep track of changes already given by the user in a dictionary and prompt when a new change is needed.
all_rows = []
changes = {}
for row in all_rows:
some_num = row[0]
if strformat.match(some_num):
continue
try:
row[0] = changes[some_num]
except KeyError:
change = input(f"\n'{some_num}' doesn't match, change to: ")
change = change.strip()
changes[some_num] = change
row[0] = change