info_outline

Solutions will be available when this assignment is resolved, or after a few failing attempts.

Advanced Nested Pyramids

Extend your previous solution to include a third parameter "order" which can be either "ASC" or "DESC. Depending of the order provided, the pyramid will be displayed in ascending order ("ASC") or descending order ("DESC"). Examples:

A pyramid with 5 levels ASC:

nested_pyramid(5, '*', 'ASC')
*
**
****
*****
******

A pyramid with 5 levels DESC:

nested_pyramid(5, '*', 'DESC')
*****
****
***
**
*

A pyramid with 3 levels ASC:

nested_pyramid(5, '#', 'ASC')
#
##
###

A pyramid with 3 levels DESC:

nested_pyramid(5, '@', 'DESC')
@@@
@@
@

Test Cases

test descending pyramid - Run Test

desc_pyramid = """
xxxxxxx
xxxxxx
xxxxx
xxxx
xxx
xx
x
""".lstrip()


def test_descending_pyramid():
    assert advanced_nested_pyramid(7, 'x', 'DESC') == desc_pyramid

test ascending pyramid - Run Test

pyramid_5_expected = """
#
##
###
####
#####
""".lstrip()


def test_ascending_pyramid():
    assert advanced_nested_pyramid(5, '#', 'ASC') == pyramid_5_expected
def advanced_nested_pyramid(height, char, order): pass