Menu

[solved] – Question 97614

1) Display the number of jokes in jokes.txt
2) Ask the user for the number of a joke
3) Display the joke
4) Display the requested joke
5) Display the requested answer

import os

# This program has read/write access to the WORKSPACE directory
jokes_filepath = os.path.join( os.environ[‘WORKSPACE’], ‘jokes.txt’ )
answers_filepath = os.path.join( os.environ[‘WORKSPACE’], ‘answers.txt’ )

# The testing system will let this program know how many lines to expect
num_of_lines = int( input() )

# Copy input into the files. Do not modify!
with open( jokes_filepath, ‘w’ ) as jokes_file:
with open( answers_filepath, ‘w’ ) as answers_file:
for _ in range( num_of_lines ):
jokes_file.write( input() + ‘n’ )
answers_file.write( input() + ‘n’ )

# Write your program below

Expert Answer


OR


Leave a Reply

Your email address will not be published. Required fields are marked *