I need help with this python programming!!!! First, think about the pattern you
ID: 3930275 • Letter: I
Question
I need help with this python programming!!!!
First, think about the pattern you see! What if you want to make the problem more generic and get the max number of odd stars to print at the bottom of the triangle?
users will input the odd number of max stars and out the corresponding triangle to the screen. Code, and include error handling for good positive ints and making sure it is an odd number.
Write a loop (or loops) to print the following picture:
print(" * ");
print(" *** ");
print(" ***** ");
Explanation / Answer
try:
# get user input
n = int(input("Enter a number:"))
# check if it is odd or not
if(n%2==1):
i = 1
while(i<=n):
# print stars and increment i by 2 until i < n
print("*"*i)
i = i+2
else:
print("Not an odd number")
except:
# error checking
print("Not a valid integer")
"""
sample output
"""