-
Log in to REPL
-
Look at the following code:
# my_building is a representation of the apartments on each floor of my 3 story building
my_building = [
['apt1a', 'apt1b', 'apt1c'],
['apt2a', 'apt2b', 'apt2c'],
['apt3a', 'apt3b', 'apt3c']
]
print("first floor: " + str(my_building[0]))
print("first floor, 3rd apartment: " + my_building[0][2])
Answer the following questions on a piece of paper:
- What would the
print
functions print? - Why does the first
print
function need thestr
function instr(my_building[0])
, but the secondprint
function does not needstr
formy_building[0][2]
? - How you would access the 2nd apartment of the 3rd floor (apt3b)?