struggling a bit understanding how to access indices in Python loops. How would you write this code in Python?
int x = 5;
for (int i = 0; i < s.length; i++) {
if (s[i] + s[i - 1] == x) {
System.out.println("Success");
}
}
So far, I have tried the enumerate method, but I don't think it's working as intended.
x = 5
for i, c in enumerate(s):
if (i, c + (i - 1), c == x):
print("Success")
Sorry if this has been asked before, but I couldn't really find a solution to this exact way of handling indices in Python loops. Would really appreciate the help.
sin your question ?sare tested together?