Using Python write a recursive function printstack that prin

Using Python, write a recursive function printstack that prints a stack of cups with a given number of rows. The function MUST be recursive and is not allowed to use a loop (but can use multiplication with strings). Hint: have the function allow an additional parameter, and indentation value, see the last test run. Sample output:

Solution

def printstack(n,in):

print \'\ \'

if(n>0):

print in*\' \'

print (n-1)*\' \'

print \'U \'*n

printstack(n-1,in)

else:

return

Using Python, write a recursive function printstack that prints a stack of cups with a given number of rows. The function MUST be recursive and is not allowed t

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site