Budget app, weird syntaxis

Hi everyone.

I’ve been hours trying to figure out what this simple syntax means, but I just don’t get it. I would be glad to read your responses.

f"{item['description'][0:23]:23}"

What is the 23 doing in its two positions? Why 23?

I’ve seen this line of code repeatedly in everyone’s code, hopefully many of you know what this actually does.

Thank you, have a nice day.

23 seems to be arbitrary number, which might be relevant only for specific implementation, so I wouldn’t focus on the number itself.

Have you tried to play around with it? Start python interpreter, define some string, and see what you will get after using similar syntax.

1 Like

I did it, I tried to play around with It and It was helpful. I’ve already found an explanation for the entire line.

Thank you so much for your recomendation and time.

1 Like