S
S
szjyakgf2022-02-27 19:23:01
Python
szjyakgf, 2022-02-27 19:23:01

How to make even columns when numbering?

I render the list like this:

cur.execute("SELECT * FROM users WHERE idspq = ?", (idspq, ))
data = cur.fetchall()
text = '\n'.join(f'{i}. {row[3]}  {row[5]}' for i, row in enumerate(data, 1))

For example, I get the following list:
1. ❌ entry1
2. ❌ entry2
3. ❌ entry3
4. ❌ entry4
5. ❌ entry5
6. ✅ entry6
7. ✅ entry7
8. ✅ entry8
9. ✅ entry9
10. ✅ entry10
11. ✅ entry11
But starting from the 10th record, a "step" begins.
How can I remove it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Gornostaev, 2022-02-27
@szjyakgf

Specify alignment in placeholders.

A
Alexander Nesterov, 2022-02-27
@AlexNest

As an option - add zeros before the numbers (if the entries < 100 - for the first nine, < 1000 - for 1-99, etc.)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question