# Getting error "itertools.permutations object at 0x0000021DB872C180"

i mean how to add multiple loop ?

my code look like this :

``````# Do the imports
import itertools
from random import choices
from time import sleep

# Some characters
characters = '123abc'

# Start a for loop with a list
for name in ['one', 'two', 'three']:
# Start a second for loop to get 3 random characters
for i in range(3):
# Print results
print(f'{name}{"".join(choices(characters, k=3))}')
# Sleep for 3 seconds (This stops the script fpr 3 seconds)
sleep(3)

a = "123"
p =  itertools.permutations(a, 2)
for j in list(p):
c2= print(*j, sep="")
results = print(itertools.permutations('characters'))
``````

results right now is :

``````
one 21b
one 1aa
one 11c

two aa2
two c21
two 2b3

three c3b
three 1bb
three ccc

12
<itertools.permutations object at 0x0000021DB872C180>
13
<itertools.permutations object at 0x0000021DB872C180>
21
<itertools.permutations object at 0x0000021DB872C180>
23
<itertools.permutations object at 0x0000021DB872C180>
31
<itertools.permutations object at 0x0000021DB872C180>
32
<itertools.permutations object at 0x0000021DB872C180>

``````

results i want like this :

``````one 21b 12
one 1aa 13
one 11c 21

>>
until a = "123" list itertools.permutations is completed
``````

thank you

You can use zip(): https://realpython.com/python-zip-function/

for l, n, o in zip(letters, numbers, operators):
print(f’Letter: {l}‘)
print(f’Number: {n}’)
print(f’Operator: {o}')

i’m still confused,

i do this

``````a = ['foo', 'bar', 'baz']
for i in a:
print(i)
``````

but results is not what i expected.

perhap some sample code is appreaciate.

thank anyway

``````a = ['foo', 'bar', 'baz']
b = [1,2,3]
for i,j in zip(a,b):
print(i,j)
``````

output:

``````foo 1
bar 2
baz 3
``````

is not what i’m looking for.

if you check my code i already done that to.

``````a = "123"
p =  itertools.permutations(a, 2)
for j in list(p):
c2= print(*j, sep="")
``````

i just dont know how to add this permutation into “characters” loop

results i want is replace “characters” into permutation / itter from a.

i hope you understand

You want to add p into the first loop, use zip():

``````a = "123"
p =  itertools.permutations(a, 2)
for i,j in zip(range(3), list(p)):
``````

Not really sure what you want to do with this line:
`results = print(itertools.permutations('characters'))`

Not really sure what you are trying to accomplish. Is this an exercise from another website? `zip()` will get the output you wanted in your first post.

I do not understand this. the results = print statement is why it’s printing <itertools.perm… line

Maybe this

``````# Do the imports
import itertools
from random import choices
from time import sleep

# Some characters
characters = '123abc'

# Get perms
nums = (itertools.permutations('123',2))

inum = [n for n in nums]

# Start a for loop with a list
for name in ['one', 'two', 'three']:
# Start a second for loop to get 3 random characters
for i in range(3):
# Print results
print(f'{name} {"".join(choices(characters, k=3))} {"".join(inum[i])}')
print()

# Sleep for 3 seconds (This stops the script fpr 3 seconds)
``````

that’s exactly i want.

thank you very much…!!!

God bless you.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.