Given below is a program that calculates the factorial of a number. Rearrange the lines of code below such that this fun
Posted: Mon Jun 06, 2022 5:48 pm
Given below is a program that calculates the factorial of a number. Rearrange the lines of code below such that this function returns the correct output as shown below. For example, if the input parameter num is 3, your function should return the factorial of 3, which is 6 (because 1 * 2*3= 6). If the input parameter num is -3, your function should return the string "Invalid input". This is because the input is a negative number. Note that you should make sure the indentation is correct! Drag from here Drop blocks here return 'Invalid input' return fact def factorial(n): fact = 1 fact *= i if n < 0: for i in range (1, n+1):