+ 1
How to generate a function that shows this kind of character art?
Function(5) Out: * * * * * * * * *
7 Réponses
+ 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)
+ 2
This is more fun, type your name
https://code.sololearn.com/cid3GT7KjUBS/?ref=app
+ 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) ]
+ 1
Maybe his/her is an assignement 😒
0
this is the easiest way to do so.
print("* *")
print(" * * ")
print(" * " )
print(" * * ")
print("* *")
0
Actually i want that by using nested loops
0
okk