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
The issue with your code is that when num1 becomes negative you are directly pri... View full answer
Get step-by-step solutions from verified subject matter experts
