In python, given a string, create a new string with all the consecutive duplicates removed | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

In python, given a string, create a new string with all the consecutive duplicates removed

Example: Input: AAABBBBCDDBBECE Output: ABCDBECE can anyone help me to solve this?

5th Aug 2020, 2:38 PM
Ashir Rahman
Ashir Rahman - avatar
3 Answers
+ 2
Ashir Rahman You have to try it out first. It is a good way of learning. If you have, then link your code here.
5th Aug 2020, 2:45 PM
Tomiwa Joseph
Tomiwa Joseph - avatar
+ 2
Hint: use a for loop and append current char in new list if it's not like prev char Join the new list
5th Aug 2020, 2:59 PM
777
777 - avatar
+ 2
Aman Kumar Please make sure your code is working right before posting answers😃😃
5th Aug 2020, 2:59 PM
Tomiwa Joseph
Tomiwa Joseph - avatar