I would like to store a list of elements based on the requirements like this:
- Loop the list and check each string
- If this string, then store the other strings within the list except the current string.
a = ["I","have","something","to","buy"]
When loop to "I" or "have" or "something" or "buy", then other elements will be stored inside the list except the current looped element. For example, we loop to "something" so "I", "have", "to", "buy" will be stored.
My code:
store = []
for x in a:
if x:
#I stuck here, I am really sorry, I know I should give more example,
#but I really cant continue after here.
My expected output:
[["have","something","to","buy"], ["I","something","to","buy"], ["I","have","to","buy"], ["I","have","something","buy"], ["I","have","something","to"]]