+ 1

How to generate a function that shows this kind of character art?

Function(5) Out: * * * * * * * * *

20th Aug 2018, 4:22 AM
Danish Aman
Danish Aman - avatar
7 odpowiedzi
+ 3
You have to find a logic behind the pattern... The simplest logic is: - set n to be row count (5 in example) - for any 'c' in n print current row pattern - Any row its composed by 'n' characters and 1 or 2 of they must be asterisks which depends on 'c'. If you see at c=0 (first line) the first and last chars are *. At second line (then c=1) the second and last less one chars are *. You can see a logic? At 'c' row you have to set the 'c' and 'n-c-1' char (checking if they have same value like at c=2 in your example)
20th Aug 2018, 6:15 AM
KrOW
KrOW - avatar
+ 2
This is more fun, type your name https://code.sololearn.com/cid3GT7KjUBS/?ref=app
20th Aug 2018, 6:39 PM
Louis
Louis - avatar
+ 1
n=int(input()) [print('{:^40}'.format('*' if i==0 else '*'+' '*(abs(i*2)-1)+'*')) for i in range(int(-n/2),int(n/2)+1) ]
20th Aug 2018, 6:33 PM
Louis
Louis - avatar
+ 1
Maybe his/her is an assignement 😒
20th Aug 2018, 8:50 PM
KrOW
KrOW - avatar
0
this is the easiest way to do so. print("* *") print(" * * ") print(" * " ) print(" * * ") print("* *")
20th Aug 2018, 5:03 AM
vamsi
0
Actually i want that by using nested loops
20th Aug 2018, 5:04 AM
Danish Aman
Danish Aman - avatar
0
okk
20th Aug 2018, 5:15 AM
vamsi