Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set the default subtitles language in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Multiline f-Strings

Give Feedback

In this lesson, you’ll learn how to write f strings over multiple lines. You’ll see three different methods of spreading strings over multiple lines using the f-string “f” character, escaping returns, and using triple quotes (""").

gilpinbmchs on April 16, 2020

I get an error after I hit <enter> when trying the ‘message = f”“”’

Ricky White RP Team on April 17, 2020

Hi @gilpinbmchs. What happens when you finish the string with the closing triple quotes?

anandxrfeu on May 26, 2020

Hello!

At 1:38 you show the syntax of escaping return with a . I dont get it. The syntax with and without ‘' seem identical. Could you please explain the ‘' use?

anandxrfeu on May 26, 2020

Hello!

At 1:38 you show the syntax of escaping return with a \. I dont get it. The syntax with and without \ seem identical. Could you please explain the \ use?

alvesmig on June 28, 2020

@ anandxrfeu Hi, the syntax without \ needs parenthesis. The one with \ don’t need parenthesis. That’s the difference between the two. I hope it would help Best regards Miguel Alves

alvesmig on June 28, 2020

Hi, why did you not explain this method? Is it bad practice?

message = f"Hi {name} \
You are a {profession} \
You were in {affiliation}"

By the way, I find the course very interesting and well taught. Best regards Miguel Alves

Become a Member to join the conversation.