Python Forum
How to aling the printing statements
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to aling the printing statements
#5
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/
Reply


Messages In This Thread
How to aling the printing statements - by Mekala - May-14-2020, 01:23 PM
RE: How to aling the printing statements - by deanhystad - May-16-2020, 05:41 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  If & Else statements not printing. blackjesus24 3 2,575 Jan-22-2020, 04:43 PM
Last Post: blackjesus24

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020