#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Felix Muzny DS 2000 - sec 4 9/16/2022 A program to greet people at our new zoo. """ """ Today's problem: Write a program, zoo.py, that represents a zoo that we're starting. First, this program should greet the user (by name, of course), then tell them what animals we have in our zoo. """ # our first function! def main(): # user info name = input("what is your name? ") print("Welcome to Monsters Inc.,", name) print() animal_decision = input("where do you want to go [reptile, aviary]? ") print(animal_decision) # option 1 - no conditionals filename = animal_decision + ".txt" animal_file = open(filename, "r") # option 2 - with condtionals # if animal_decision == "reptile": # animal_file = open("reptile.txt", "r") # else: # animal_file = open("aviary.txt", "r") # 2. do stuff # common error B: misspell readline line = animal_file.readline() print("line:", line) line = animal_file.readline() print("line:", line) line = animal_file.readline() print("line:", line) # 3. close the file animal_file.close() # # animal info # print("Our animals:") # # 1. open the file in "r"ead mode # # Common error A: FileNotFound - "animal.txt" # animal_file = open("animals.txt", "r") # # 2. do stuff # # common error B: misspell readline # line = animal_file.readline() # print("line:", line) # line = animal_file.readline() # print("line:", line) # line = animal_file.readline() # print("line:", line) # # 3. close the file # animal_file.close() # call the function main()