Python Forum
fmt_directory_entry = "{counter:>02}. {director:<52} {avg}"
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
fmt_directory_entry = "{counter:>02}. {director:<52} {avg}"
#1
What exactly is going on with the {counter:>02} parameter in the fmt_directory_entry assignment? In particular, how is it effected that 0 should be inserted to the left of counter if len(counter) > 2? Is there a way I could make it be an other symbol other than 0, say the letter i?

def print_results():
    fmt_directory_entry = "{counter:>02}. {director:<52} {avg}"
    for counter, director_info in enumerate(top_directors_with_at_least_four(),
                                            1):
        director, rating = director_info[0]

        print(fmt_directory_entry.format(counter=counter, director=director,
                                         avg=rating))
Output:
01. Sergio Leone 8.5 02. Christopher Nolan 8.4 03. Quentin Tarantino 8.2 ... 10. Alfonso CuarĂ³n 7.8 11. Peter Jackson 7.7 12. Martin Scorsese 7.7
Reply


Messages In This Thread
fmt_directory_entry = "{counter:>02}. {director:<52} {avg}" - by ClassicalSoul - Apr-09-2020, 01:46 PM

Forum Jump:

User Panel Messages

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