Question: I am having the same issue with this LAB: Number pattern Here is my code: def print_num_pattern(num1,num2): if (num1 == 0 or num1 < 0):

I am having the same issue with this  LAB: Number pattern

Here is my code:

def print_num_pattern(num1,num2):

if (num1 == 0 or num1 < 0): print(num1, end = ' ') return

print(num1, end = ' ') print_num_pattern(num1 - num2, num2)

print(num1, end = ' ')

if __name__ == "__main__": num1 = int(input()) num2 = int(input()) print_num_pattern(num1, num2)

My output is:

12 9 6 3 0 3 6 9 12

The Expected output:

12 9 6 3 0 -3 0 3 6 9 12

Please Help me.


Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The issue with your code is that when num1 becomes negative you are directly pri... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!