crzcas

smiley face with asterisks

Dec 21st, 2020 (edited)
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.50 KB | None | 0 0
  1. # define a 2D list of characters that represents a smiley face
  2. smiley = [[" "," "," "," "," "," "," "," "," "," "," "," "],
  3.           [" "," "," ","*"," "," "," "," ","*"," "," "," "],
  4.           [" "," ","*","*","*"," "," ","*","*","*"," "," "],
  5.           [" "," ","*","*","*"," "," ","*","*","*"," "," "],
  6.           [" "," "," ","*"," "," "," "," ","*"," "," "," "],
  7.           [" "," "," "," "," "," "," "," "," "," "," "," "],
  8.           ["*","*"," "," "," "," "," "," "," "," ","*","*"],
  9.           [" ","*","*"," "," "," "," "," "," ","*","*"," "],
  10.           [" "," ","*","*","*","*","*","*","*","*"," "," "],
  11.           [" "," "," ","*","*","*","*","*","*"," "," "," "]]
  12.  
  13. # find the total number of rows
  14. total_rows = len(smiley)
  15.  
  16. # repeat the outer loop based on the total number of rows
  17. for row in range(total_rows):             #  <----- Here is missing the argument of range (total_rows).
  18.  
  19.     # find the number of values in the current row
  20.     total_cols = len(smiley[row])
  21.    
  22.     # repeat the inner loop based on the total number of cols
  23.     for col in range(total_cols):         #  <----- Here is missing the 'for' inner loop to col (col, total_cols).
  24.    
  25.        
  26.         # output the value from the current row and column
  27.         # setting end to an empty string stops a new line from being created
  28.         print(smiley[row][col], end="  ")    #  <----- Here is missing the arguments of array 2D smile (row , col)
  29.        
  30.     # output a new line after each row has ended
  31.     print("\n")
Add Comment
Please, Sign In to add comment