identify the syntax and logical errors in the code. def print_pattern(): prev2 = 0
Fantastic news! We've Found the answer you've been seeking!
Question:
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
Related Book For
Data Structures and Algorithms in Python
ISBN: 978-1118290279
1st edition
Authors: Michael T. Goodrich, Roberto Tamassia, Michael H. Goldwasser
Posted Date: