Advertisement
Guest User

Untitled

a guest
Feb 26th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. '''The code is meant to skip adding the character "a" and any other character that comes after "a". For this, I check if string's [i th] index = a, and add 1 to index, so that new index will be able to skip the character coming after "a". But this does not seem to be happening. Why is it so ?'''
  2.  
  3. str1 = "abcde"
  4. str2 = ""
  5. for i in range(len(str1)):
  6. if str1[i] == "a":
  7. i +=1
  8. continue
  9. else:
  10. str2 += str1[i]
  11. print (str2)
  12.  
  13. #Output is bcde. But why ?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement