Quick actions

cmd+k|ctrl+k

Navigation

Languages

First GUI

Snippet info

Language

Python

Visibility

public

Author

udditgupta

Created

2025-11-04T11:05:18.606108Z

Updated

2025-11-04T11:05:29.845876Z


# need to know 'end' argumnt paseed to prit func for this, default is newline

#Exercise!
#Display the image below to the right hand side where the 0 is going to be ' ', and the 1 is going to be '*'. This will reveal an image!
picture = [
  [0,0,0,1,0,0,0],
  [0,0,1,1,1,0,0],
  [0,1,1,1,1,1,0],
  [1,1,1,1,1,1,1],
  [0,0,0,1,0,0,0],
  [0,0,0,1,0,0,0]
]

# see it failed , now see below
#for i in len(picture):
 #   for j in len(picture[i]):
  #      if picture[i][j] == 0:
   #         print(' ')
    #    else:
     #       print('*')
     
    
for img in picture:
    for pixel in img:
        if pixel:
            print('*', end = '')
        else:
           print(' ', end = '')
    print('')
 
# best practice, what is good code?
# clean, readability, predictablity, DRY don rpeeat usble, maing cdeo reusable
# just change at one loc

fill ='*'
empty = ' '

for img in picture:
    for pixel in img:
        if pixel:
            print(fill, end = '')
        else:
           print(empty, end = '')
    print('')





     
INFO