fork download
  1. # your code goes here
  2.  
  3. a = 'this day is a beautiful day'
  4. b = 'this day is awful'
  5.  
  6. x = [x for x in b.split() if x in a.split()]
  7.  
  8. for i in range(len(x)):
  9. for j in range(i, len(x)+1):
  10. word = ' '.join(x[i:j])
  11. if word in a:
  12. print(word)
Success #stdin #stdout 0.09s 10104KB
stdin
Standard input is empty
stdout
this
this day
this day is

day
day is

is