fork(7) download
  1. # your code goes here
  2. #test= 'abab'
  3. #for i in range(len(test)):
  4. # for k in range(len(test)-i):
  5. # print test[i:i+k+1]
  6. def uniq_substring(test):
  7. lista=[]
  8. [lista.append(test[i:i+k+1]) for i in range(len(test)) for k in range(len(test)-i) if test[i:i+k+1] not in lista and test[i:i+k+1][::-1] not in lista]
  9. print lista
  10.  
  11. uniq_substring('rohit')
  12. uniq_substring('abab')
  13.  
  14.  
Success #stdin #stdout 0.01s 9016KB
stdin
Standard input is empty
stdout
['r', 'ro', 'roh', 'rohi', 'rohit', 'o', 'oh', 'ohi', 'ohit', 'h', 'hi', 'hit', 'i', 'it', 't']
['a', 'ab', 'aba', 'abab', 'b', 'bab']