I have to create a program to print an inverted triangle in python.
When I was running it in Sublime Text 3 it did not run.
By that, I mean that it did not even print a syntax error.
def triangle():x = 1for i in range(11,1):print('*' * 10 - x)x = x + 1return
triangle()
Your range is empty
>>> list(range(11,1))
[]
Therefore, nothing is printed as the loop does nothing
You need the step parameter
>>> list(range(11,1,-1))
[11, 10, 9, 8, 7, 6, 5, 4, 3, 2]
Before thinking the code "isn't working", just put a print('calling function')
and print('in function')
in the code while you test it