Python for the .NET developer Transcripts
Chapter: Web frameworks
Lecture: Improved price display

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Well, this is nice, I really love how it came out.
0:02 Except, if you look carefully
0:04 wouldn't it be nice if there was a comma right there?
0:07 1,299. If we have more than, you know, three digits?
0:13 So, it's really easy to do that in Python
0:15 and we just use string.format.
0:16 I don't think in the course yet
0:18 we've used string.format, we've only used f-strings
0:21 Python's equivalent of C#'s string interpolation
0:24 but we're going to do that here to get a better representation.
0:27 There's probably a ton of ways to do this
0:29 but we can just put two quotes here
0:31 and we can say, we want something formatted in here
0:34 zero, quoting point, and it has commas for digit grouping
0:39 and we say .format, this.
0:43 Let's see if I got that right, whoops, no, I did not.
0:45 There we go, let's see if I got that right.
0:47 Try again, ta-da, there it is.
0:51 So, you know, nothing major or groundbreaking
0:53 but if you want to control the two string bit here
0:56 you just write a little Python expression
0:57 with a string.format, and you can go crazy.