f Strings – Python Quick Tips



This python quick tips video covers how to use python f strings. F strings are a fast way to build strings that involve the use of variables. It allows you to avoid using slower methods like format and the % sign.

Like this video for more python quick tips.
*****
Enroll in The Fundamentals of Programming w/ Python

Instagram:
Website
Twitter:…

, , , ,

18 thoughts on “f Strings – Python Quick Tips

  1. Hey Tim, great video on string formatting options. Only note I'd add is f-strings are fairly new, so you need Python 3.6 to use them. I'm positive you know that, but didn't want 2.7 or older 3.x version users to be surprised they can't use this cool feature.

  2. Just a correction on line 5 or "ex2". You absolutely don't need any index in the curly brackets. Just go with {} because .format will use them in order anyways. Im not 100 percent sure but it could be the same with the % sign.

    It works in methods. Never tried it outside of them.

  3. When passing in a variable containing a number into a placeholder with multiple values ones, tenths, hundredths, thousands, ten-thousands, etc if you add a colon followed by a comma it'll format said number for you
    `n = 10000000
    f_num = f"{n:,} times"
    Output: 10,000,000 times
    `

Leave a Reply

Your email address will not be published. Required fields are marked *