'How to add space in data/String using python?
I have some data in my database. It looks like 84819010 and I wanted to make it like 8481 90 10 I use the following code and get the following error:
information_table = data.cur.execute("""
SELECT p.gs_com_code, p.gs_code FROM product p
INNER JOIN (
SELECT pp.p_gs_com_code From product_purchase pp
) t ON t.p_gs_com_code = p.gs_com_code
""",).fetchall()
for info in information_table:
t = info[1]
sep = "{}{}{}{} {}{} {}{}"
gs_code = sep.format(*t)
print(gs_code)
Error:
gs_code = sep.format(*t)
IndexError: Replacement index 7 out of range for positional args tuple
My information looks like 84819010 and I wanted to make it like 8481 90 10
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
