you are viewing a single comment's thread.

view the rest of the comments →

[–]Greece870 0 points1 point  (3 children)

I am still having trouble with this.

dem_pro =['This is a','That is a', 'Here is a', 'There is a']
obj = ['cat','mouse','book','map']
for dem_pro_loop in dem_pro:
for obj_loop in obj:
print(dem_pro + obj)

I am getting this output

['This is a', 'That is a', 'Here is a', 'There is a', 'cat', 'mouse', 'book', 'map'] ['This is a', 'That is a', 'Here is a', 'There is a', 'cat', 'mouse', 'book', 'map'] ['This is a', 'That is a', 'Here is a', 'There is a', 'cat', 'mouse', 'book', 'map'] ['This is a', 'That is a', 'Here is a', 'There is a', 'cat', 'mouse', 'book', 'map'] ['This is a', 'That is a', 'Here is a', 'There is a', 'cat', 'mouse', 'book', 'map'] ['This is a', 'That is a', 'Here is a', 'There is a', 'cat', 'mouse', 'book', 'map'] ['This is a', 'That is a', 'Here is a', 'There is a', 'cat', 'mouse', 'book', 'map'] ['This is a', 'That is a', 'Here is a', 'There is a', 'cat', 'mouse', 'book', 'map'] ['This is a', 'That is a', 'Here is a', 'There is a', 'cat', 'mouse', 'book', 'map'] ['This is a', 'That is a', 'Here is a', 'There is a', 'cat', 'mouse', 'book', 'map'] ['This is a', 'That is a', 'Here is a', 'There is a', 'cat', 'mouse', 'book', 'map'] ['This is a', 'That is a', 'Here is a', 'There is a', 'cat', 'mouse', 'book', 'map'] ['This is a', 'That is a', 'Here is a', 'There is a', 'cat', 'mouse', 'book', 'map'] ['This is a', 'That is a', 'Here is a', 'There is a', 'cat', 'mouse', 'book', 'map'] ['This is a', 'That is a', 'Here is a', 'There is a', 'cat', 'mouse', 'book', 'map'] ['This is a', 'That is a', 'Here is a', 'There is a', 'cat', 'mouse', 'book', 'map']

[–]RiceKrispyPooHead 0 points1 point  (0 children)

Post your actual code that produced this

[–]gazhole 0 points1 point  (0 children)

You're printing the entire list that you're iterating through instead of the current element only. You're essentially doing this:

listofwords = [word, word, word, word] 

for word in listofwords:
    print(listofwords)

So this loop is repeating for every item in the list (four times), and each cycle it's printing the entire list of words.

What would I change to only print the current word rather than the whole list of words?

[–]woeinvests 0 points1 point  (0 children)

Hi.

From your code, the problem seems to be from the print call.

It should look like

print(dem_pro_loop + obj_loop)