May-16-2020, 05:41 AM
The f'Starting index...' thing is a formatted string literal. It is a new (V3.6) shorthand for the string format command. Text inside the curly brackets is evaluated and replaced. In my example {match.start():<2} is evaluated and then some formatting is applied.
Match.start() becomes '3', then the :<2 says "I want you to be 2 wide and left justified", '3 '. The formatting codes are documented here:
https://docs.python.org/3.8/library/string.html
And you can find more information about fstrings here:
https://realpython.com/python-f-strings/
Match.start() becomes '3', then the :<2 says "I want you to be 2 wide and left justified", '3 '. The formatting codes are documented here:
https://docs.python.org/3.8/library/string.html
And you can find more information about fstrings here:
https://realpython.com/python-f-strings/