1 Minute Read #17 -strings in #python*
▻https://hackernoon.com/1-minute-read-17-strings-in-python-4c13934ca684?source=rss----3a8144eabf
1 Minute Read #17: f-strings in Python*How long is a piece of string? If it is as long as the many ways to manipulate strings in Python, then it is mighty long indeed. Python 3.6, released in 2016, introduced a whole new way to format strings. Known as ‘formatted-string literals’, they are a much more efficient than anything that preceded them. For example below is a standard way of handling strings using .format :You can be cute with this, and change the order (the index) in which the variables are called:Endless fun can be had in this manner…however…there is another way:Note the use of the (f”Hello…”) here — the f can be capitalised to F(“Hello…”), and it tells Python that you wish to use previously declared variables in this string.f-strings disturb old-school Pythonistas who have got so very used (...)