I need to change the first occurrence of a 1 into a 0 for each element of a string in list, but it changes everything:
a, b = input().split()
a = int(a)
d=[]
for x in range(1,a+1):
globals()['side%s' % x] = input("Enter something: ")
d.append(globals()['side%s' % x])
d = [s.replace('1', '0') for s in d]
print(d)
Example:
4 1 // 4 number of inputs, 1 - number of possible changes to string
0101
0010
0100
1000
need to be
0001
0000
0000
0000
1with0and leave the other occurences unchanged?replace()takes an optional third argument, the maximum number of times to replace. For example,replace('1', '0', 1)will perform the replacement on only the first instance