-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
  • 119,623
  • 25
  • 170
  • 301
user8638151
  • 21
  • 1
  • 7

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,556
  • 4
  • 19
  • 29