+ 2
how can i right a program for giving me staras?
A program that gets an input as int like n if n>=3 it gives me a triangle of stars for example when n=6 the out put is * ** *** **** ***** ****** ***** **** *** ** *
3 ответов
+ 2
banoo use stars(num) only
When you are using print inside a function and not returning any value, using print(stars(num)) returns none
+ 3
for i in range(1,6+1):
print(i*"*")
for i in range(6-1,0,-1):
print(i*"*")
+ 3
Abhay thanks for your help
I wrote this and it works but I dont understand why at the end it shows None
How can I avoid this?
def stars(n):
if n>=3:
for i in range(1,(n+1)):
print (i*"*")
for i in range((n-1),0,-1):
print(i*"*")
num=int(input("type a number:")
print(stars(num))
>>>
type a number:3
>>>
*
**
***
**
*
None