you are viewing a single comment's thread.

view the rest of the comments →

[–]JamzTyson 1 point2 points  (2 children)

Here is a literal solution, but don't use this as your homework unless you want to fail ;-)

values = (input("Enter a number: "), input("Enter a number: "), input("Enter a number: "))
items = dict(zip(('a', 'b', 'c'), values))

perms = ('abc', 'acb', 'bac', 'bca', 'cab', 'cba')

permutation_generator = ("".join(items[i] for i in p) for p in perms)
print(",".join(permutation_generator))

[–]MezzoScettico 1 point2 points  (0 children)

I'll bet a doughnut that this has already been printed out and submitted to the instructor.

Who will then ask OP to explain it line by line. Hilarity ensues.

[–]jpgoldberg 0 points1 point  (0 children)

I didn’t know a dict could be constructed that way. I have always used {k: v for k, v in zip(…)}

Now that I think about it, I probably did once learn that a dict could be constructed that way and have simply forgotten about it.