Write a function called show_palindromic_triangle that takes a number as an argument and
prints a Palindromic Triangle in the function.
[Must reuse the show_palindrome() function of the previous task]
===================================================================
Hints(1):
Need to use both print() and print( , end = " ") functions
===================================================================
Example1:
Function Call:
show_palindromic_triangle(5)
Output:
1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
1 2 3 4 5 4 3 2 1
===================================================================
Example2:
Function Call:
show_palindromic_triangle(3)
Output:
1
1 2 1
1 2 3 2 1
def show_palindrome(n):
for i in range(n):
print(i+1, end=' ')
for i in range(n-1,0,-1):
print(i, end=' ')
print('')
def show_palindromic_triangle(n):
for i in range(n):
show_palindrome(i+1)
show_palindromic_triangle(5)
Comments
Leave a comment