Question

python: Write a function named "write_values" that takes a key-value store mapping strings to strings as...

python: Write a function named "write_values" that takes a key-value store mapping strings to strings as a parameter and writes the values of the input to a file named "persuade.txt" with one element per line. If a file named "persuade.txt" already exists it must be overwritten. The function should not return any value

0 0
Add a comment Improve this question Transcribed image text
Answer #1
def write_values(store):
    f = open("persuade.txt", "w")
    for value in store.values():
        f.write(value + "\n")
    f.close()


d = {
    "key1": "value1",
    "key2": "value2",
    "key3": "value3"
}
write_values(d)

Add a comment
Know the answer?
Add Answer to:
python: Write a function named "write_values" that takes a key-value store mapping strings to strings as...
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