For example i inputted "ABC"
The output should be:
*** ** ***
* * * * *
*** ** *
* * * * *
* * ** ***
I only tried the letter A but it results an error.
Can someone help me do it in plain python without any modules
text = input("Enter my text: ").split()
A = [3, [1,0,1], 3, [1,0,1], [1,0,1]]
for i in range(text+1):
if text[i] == 'A':
print("*" * A[i])
>Solution :
That representation seems inconsistent, if you wanted to use a matrix to represent which elements are asterisks I’d suggest
A = [[1,1,1], [1,0,1], [1,1,1], [1,0,1], [1,0,1]]
Then you can loop over each row and print out either an asterisk or whitespace as appropriate
for row in A:
print(''.join('*' if s == 1 else ' ' for s in row))
***
* *
***
* *
* *