-2

i wrote a code to print a list of a number's prime factorization, and for example, if the user input was "18", it would output "[2, 3, 3]". how do i make it print in such a way that it follows this format: "18 = 2x3x3"?

martineau
  • 112,593
  • 23
  • 157
  • 280

1 Answers1

0

Here's a way:

l = [2,3,3]
number = 18

def printList(number, l):
    print(str(number) +" = " + "x".join(str(i) for i in l))

printList(number, l)

Result:

18 = 2x3x3

Although I don't think that is that much of a challenge to write a piece of code that does this job.

Vasilis G.
  • 7,174
  • 4
  • 19
  • 28