jeudi 13 mai 2021

How to draw "U" pattern with stars? [closed]

I am trying to draw patterns with "*" but I can not because after for loop I can not write true if statement codes.

Here is example of "Z" pattern;

    result_str="";    
for row in range(0,7):    
    for column in range(0,7):     
        if (((row == 0 or row == 6) and column >= 0 and column <= 6) or row+column==6):  
            result_str=result_str+"*"    
        else:      
            result_str=result_str+" "    
    result_str=result_str+"\n"    
print(result_str)

The breakpoint is if statement, I did not understand the if statement.

Aucun commentaire:

Enregistrer un commentaire