I am writing some code, and would like to add a conditional statement such that as we loop through stringg
below, if we hit an integer, then ... we do something (doesn't matter what)
stringg = "3[a]2[bc]"
But the thing is that even the 3 and 2 are strings at the moment- how can I loop through stringg while checking if each character is an integer?
for i in stringg:
if isinstance(i,int):
print("Hello")
The above loop returns nothing
to my point made above. Any ideas how the above can be achieved?
One other thing that came to mind is to do int(i) as we loop, but I couldn't figure out how to do this.