Question

python question Complete the function append_text() to append the string, "I appended it" to the file,...

python question

Complete the function append_text() to append the string, "I appended it" to the file, fname.

Note that you will need to open the file in the appropriate mode

def append_text("my1stwrite.txt"):

--------------------------------------------

my1stwrite.txt content :

Cat
Fish
Tiger
Cougar

0 0
Add a comment Improve this question Transcribed image text
Answer #1
def append_text(fileName):
    with open(fileName, "a") as myfile:
        myfile.write("I appended it")

# Testing
append_text("my1stwrite.txt")

Cat
Fish
Tiger
Cougar

After running code

Cat
Fish
Tiger
Cougar
I appended it
Add a comment
Know the answer?
Add Answer to:
python question Complete the function append_text() to append the string, "I appended it" to the file,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT