# Convert the word into lowercase and check the count for each letterdef duplicate_encode(word): new=[] for i in word.lower(): if word.lower().count(i) == 1: new.append('(') else: new.append(')') return ''.join(new) # with list comprehension def duplicate_encode(word): return ''.join(['(' if word.lower().count(i) == 1 else ')' for i in word.lower()])
Tuesday, February 1, 2022
Duplicate Encoder Codewars Python
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment