Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python3
- def problem2(w,a,L1,L2):
- if IsStringInL(w,L1) or IsStringInL(w,L2):
- return True
- myBool = False
- for i in range(0, len(a)):
- if (IsStringInL(w[0:a[i]],L1) or IsStringInL(w[0:a[i]],L2)):
- myBool = problem2(w[a[i]:len(w)],a,L1,L2)
- if myBool == True:
- return myBool
- return False
- def IsStringInL(w,L):
- if w in L:
- return True
- return False
- if __name__=="__main__":
- w = input("Enter a string to test: ")
- a = [5,4,3] # array containing all possible string lengths in L1 and L2
- L1 = ["fish", "foo", "fun", "flip", "fin", "fruit"]
- L2 = ["pop", "pomp", "pump", "puff", "pat", "poot"]
- print(problem2(w,a,L1,L2))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement