File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -239,8 +239,9 @@ But that gets complicated if you have many things to add.
239239Instead it's recommended to use string formatting. It means putting
240240other things in the middle of a string.
241241
242- Python has two ways to format strings. One is not better than the other,
243- they are just different. The two ways are:
242+ Python has multiple ways to format strings. One is not necessarily
243+ better than others, they are just different. Here's a few ways to solve
244+ our problem:
244245
245246- ` .format() ` -formatting, also known as new-style formatting. This
246247 formatting style has a lot of features, but it's a little bit more
@@ -271,7 +272,17 @@ they are just different. The two ways are:
271272 >> >
272273 ```
273274
274- Both formatting styles have many other features also:
275+ - f- strings are even less typing, but new in Python 3.6 . ** Use this only if
276+ you know that nobody will need to run your code on Python versions older
277+ than 3.6 .** Here the f is short for " format" .
278+
279+ ```py
280+ >> > f " My name is { name} and I'm on the { channel} channel on { network} . "
281+ " My name is Akuli and I'm on the ##learnpython channel on freenode."
282+ >> >
283+ ```
284+
285+ All of these formatting styles have many other features also:
275286
276287```py
277288>> > ' Three zeros and number one: {:04d } ' .format(1 )
You can’t perform that action at this time.
0 commit comments