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.

f-Strings Conclusion—Go Forth and Format!

Give Feedback

This lesson concludes Python 3’s f-Strings: An Improved String Formatting Syntax. You’ll watch a review of everything you have learned in this course.

JulianV on March 20, 2019


Bomes on March 23, 2019

Great tutorial! Thanks

Peter D K on March 26, 2019

f-Strings are somewhat smart! Thanks

davebmw325 on April 5, 2019

ExcellentTutorial. ShameThisCommentsBoxSpacebarDoesntWorkItJustSeemsToActAsThePauseButton.

Chris Bailey RP Team on April 9, 2019

Thanks davebmw325, I mentioned the issue of the spacebar not working to Dan. Were you using a mobile device (phone or tablet) at the time? I experienced the same thing when I tried to reply from my iPad.

Dan Bader RP Team on April 17, 2019

@davebmw325: Thanks for the heads up :) This was an issue with the comments field that affected Safari on iOS. I’m rolling out a fix now, so this should be resolved shortly.

rklyba on June 24, 2019

Thank you Chris for this course.

Mallesham Yamulla on Sept. 2, 2019

Many thanks for taking us though the concepts from Old String Formating to New F string formatting.. Highly recommended to the python folks…

teodorwisniewski on Oct. 20, 2019

Thanks you Chris, it is very useful and allowed me to understand some messy syntaxes used by some developers around strings.

Pygator on Dec. 24, 2019

Always informative and right to the point Chris!

km on Jan. 6, 2020

THanks a lot.

Phil M on Feb. 14, 2020

Excellent - thank you!

mikesult on Feb. 21, 2020

Thanks for reviewing the old style of formatting in addition to the f-string. I especially liked your discussion about the use of different type of quotes and triple quote usage.

Zarata on April 30, 2020

Yes, thanks. Two questions (or maybe 3): a) Are there other “special” flags that trigger different behaviors such as “!r” to use the representation rather than string? b) Are there flags and format codes as in “old style” to get output presentations precisely the way one would wish (decimals to certain number of places, time formats, etc.), c) Is there another course or video showing such depths?

Chris Bailey RP Team on April 30, 2020

Hi @Zarata,

a) Yes. There are a couple of others, !s Convert with str(), !a Convert with ascii()

b) Yes. The old style flags work here also.

>>> temperature = 78.8765
>>> print(f'Today it was {temperature:.2f}') # Float to 2 decimal places
Today it was 78.87

c) Not a course as of yet, but a detailed article here on Real Python. A Guide to the Newer Python String Format Techniques This covers the old style .format() methods, which f-strings support, and the conversions. I hope this helps!

alvesmig on June 28, 2020

Thank you

Become a Member to join the conversation.