Adding elements together as if im just placing them next to eachother?

1 day ago 2
ARTICLE AD BOX

I think what you're after is all of the permutations of [1,2,3], but you only want 2 numbers at a time.

Check out the [itertools.permutations]<https://docs.python.org/3/library/itertools.html#itertools.permutations> function.

I played around with the permutations function, but I found that I couldn't get anything useful unless I converted it to a list:

>>> from itertools import permutations >>> plist = list(permutations('123', 2)) >>> plist [('1', '2'), ('1', '3'), ('2', '1'), ('2', '3'), ('3', '1'), ('3', '2')]

Probably you want to combine the individual tuples. For example the first tuple ('1', '2') you would like to be '12' . To do just the first tuple, you could do plist[0][0] + plist[0][1] . plist[n] gives you the nth tuple and plist[n][m] gives you the mth element of the nth tuple. For your project, you probably want to do this all in a for loop.

Read Entire Article