Question: identify the syntax and logical errors in the code. def print_pattern(): prev2 = 0 prev = 1 print(prev)
identify the syntax and logical errors in the code.
def print_pattern():
prev2 = 0
prev = 1
print(prev)
for i in range(3, rows + 2):
for j in range(i):
nextVal = prev2 + prev
print(nextVal, end=' ')
prev2 = prev
prev = nextVal
print('Display pattern...')
num == 1
while num > 0
num = int(input('Enter the number of rows, 0 to exit: '))
if num > 0:
print_pattern(num)
The expected output is:
Display pattern.
Enter the number of rows, 0 to exit: 4
1
1 2
3 5 8
13 21 34 55
Step by Step Solution
There are 3 Steps involved in it
There are several syntax and logical errors in the provided code Heres the corrected version python def printpatternrows prev2 0 prev 1 printprev for ... View full answer
Get step-by-step solutions from verified subject matter experts
