0
Why code is not running?
a="ABCDCDCDC" b="CDC" i=0 def sample(x,y): while i<len(x): x[i:]==y print(i) i=i+1 c=(sample(a,b)) print(c)
1 Answer
0
i is not a global variable, and needs to be declared in the function.
Another tip, define functions first then start your code. That is put your variable declarations after defining the functions. This improves readability.
Edit: also x[i:] == y is semantically null. That is it does not do anything meaningful.



