I want to traverse the for loop to find all the occurrences of "%" followed by an integer and replace them with another word.
for x in format:
if x is "%":
finder = format.find("%")
val = format[finder + 1]
index = int(format[finder + 1])
print("Index value is %d" % index)
replace = args[index]
print(replace)
str = format.replace(val, replace)
return str
If there is more than one "%" in format(i.e string) then only integer, is getting replaced.
Eg: format : "%1 greets %0" and args = "Bob", "Alex"
The output should be : "Alex greets Bob"
But what I'm getting is "Alex greets %0"