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"?
Asked
Active
Viewed 42 times
-2
-
Provide your code – Sandeep Lade Nov 05 '17 at 09:50
1 Answers
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