Write an Attribution
Beginner · Write the code · from Legal and Ethical Concerns: Copyright, Plagiarism and Open Licenses
From the lesson: Legal and Ethical Concerns: Copyright, Plagiarism and Open Licenses
Anything you make on a computer, from a song to a game level, belongs to someone, and computers make it possible to copy that work in seconds.
Read the lessonWrite format_attribution(title, creator, source, license_name) that returns a credit line in this form:
"Title" by Creator (source), licenseRemove extra spaces from the start and end of title and creator. If creator is empty after that, write an unknown creator in its place.
format_attribution("Sunset", "Ana Ruiz", "flickr.com", "CC BY 4.0")
-> '"Sunset" by Ana Ruiz (flickr.com), CC BY 4.0'def format_attribution(title, creator, source, license_name):
# Build the credit line with an f-string
pass
What Check runs
Your code runs first, then each of these lines, and 2 more that stay hidden. The output must match exactly.
| Runs | Expected output |
|---|---|
| print(format_attribution("Sunset", "Ana Ruiz", "flickr.com", "CC BY 4.0")) | "Sunset" by Ana Ruiz (flickr.com), CC BY 4.0 |
| print(format_attribution("Rain Loop", "DJ Kofi", "freesound.org", "CC0")) | "Rain Loop" by DJ Kofi (freesound.org), CC0 |
More Computing Ethics exercises
- Does the License Allow It?Intermediate
- A Tiny Plagiarism CheckerIntermediate