We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Python
- Strings
- Merge the Tools!
- Discussions
Merge the Tools!
Merge the Tools!
+ 1 comment Why does it work? I thought that a set doesn't keep the order of the elements.
for i in range(0, len(string), k): print(''.join(list(set(string[i : i + k]))))
+ 0 comments x = 0 while x < len(string): print("".join(list(dict.fromkeys(list(string[x:x + k]))))) x += k
+ 0 comments another one liner solution (python 3.7+)
print( *[ "".join( list( dict.fromkeys(string[i: i+k]) ) ) for i in range(0, len(string), k)], sep="\n")
+ 0 comments l = len(string) // k print(l)
for i in range(0, len(string), k): s = '' s += string[i] g=0 for j in range(i + 1, i + k): c = False g += 1 for h in range(g): if string[j:j + 1] != string[i + h]: c = True else: c = False break if c: s += string[j:j + 1] print(s)
+ 0 comments for i in range(int(len(string)/k)): m='' for j in range(k): if string[i*k+j] not in m: m=m+string[i*k+j] print (m)
Load more conversations
Sort 2406 Discussions, By:
Please Login in order to post a comment