I have been given the following string 'abcdea' and I need to find the repeated character but remove the first one so the result most be 'bcdea' I have tried to following but only get this result
def remove_rep(x):
new_list = []
for i in x:
if i not in new_list:
new_list.append(i)
new_list = ''.join(new_list)
print(new_list)
remove_rep('abcdea')
and the result is 'abcde' not the one that I was looking 'bcdea'
>Solution :
Change
new_list = ''.join(new_list)
to
new_list = ''.join(new_list[1:]+[i])
(and figure out why! Hint: what’s the condition of your if block? What are you checking for and why?)