Solution 1

``````def advanced_nested_pyramid(height, char, order):
pyramid = ''

for level in range(1, height + 1):
row = ''
if order == 'ASC':
range_limit = level
else:
range_limit = height - level + 1

for c in range(range_limit):
row += char

row += '\n'
pyramid += row

return pyramid
``````

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 -

``````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 -

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

def test_ascending_pyramid():
assert advanced_nested_pyramid(5, '#', 'ASC') == pyramid_5_expected
``````