Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''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 ?'''
- str1 = "abcde"
- str2 = ""
- for i in range(len(str1)):
- if str1[i] == "a":
- i +=1
- continue
- else:
- str2 += str1[i]
- print (str2)
- #Output is bcde. But why ?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement