Issue
I am making a flask project right now and I need to return multiple values from a function. Here is my code:
return f"Title: {volume_info['title']}" \
f"Author: {prettify_author}" \
f"Page Count: {volume_info['pageCount']}" \
f"Publication Date: {volume_info['publishedDate']}"
Here is my output: output picture
It is all on one line, but I would like all the sections to be on different lines. Can anyone help?
Solution
If your output is going to a file or to the console, you can use a newline character:
return f"Title: {volume_info['title']}\n" \
f"Author: {prettify_author}\n" \
f"Page Count: {volume_info['pageCount']}\n" \
f"Publication Date: {volume_info['publishedDate']}\n"
If you're sending the output to a web browser, you'll need to do something different, like an HTML line break:
return f"Title: {volume_info['title']}<br/>" \
f"Author: {prettify_author}<br/>" \
f"Page Count: {volume_info['pageCount']}<br/>" \
f"Publication Date: {volume_info['publishedDate']}<br/>"
Answered By - Scovetta
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.