Remove Consecutive Duplicates

There is a logical error in this .
What if there is consecutive duplicates at the end of the string.
Like cooodinggg.
This code doesnt tackle with this

hi sukrit,
code in this video works perfectly fine.
If there is any other code,please let me know.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.