I have successfully created a code to print a horizontally flipped triangle using a while loop. Now although it works, I was wondering if i could simplify this i.e. without using a "store" variable. But i want to keep it using a while loop
Current code is:
myLen = int(input("Enter the number of rows: "))
while myLen < 1 or myLen> 40:
print("The number of rows must be greater than 1 and less than 40")
myLen = int(input("Enter the number of rows: "))
myNewLen=1
store=myLen
while myNewLen <=store:
print((" "*(myLen-1))+"*" * myNewLen)
myNewLen=myNewLen+1
myLen=myLen-1
Which will print out a result of:
*
**
***
****
*****
I was wondering how i could simplify this code for efficiency.
myLenis undefined