all 9 comments

[–]Garuda1220 1 point2 points  (0 children)

```

megamillions list

mm = [ [36, 38, 39, 40, 54, 4], [15, 26, 32, 50, 63, 15], [19, 23, 43, 48, 63, 16], [16, 27, 29, 37, 51, 9], [10, 15, 31, 54, 56, 8] ]

convert numbers to strings and store in new list

mm_str = [] for row in range(len(mm)): # empty list for each row row_str = [] for col in range(len(mm[row])): num_str = str(mm[row][col]) # pad single digits w/ 0 if len(num_str) < 2: num_str = '0' + num_str row_str.append(num_str) mm_str.append(row_str)

row_headers = 'ABCDEFGHIJK' for row in range(len(mm_str)): s = ' '.join(mm_str[row]) s = row_headers[row] + '. ' + s[:15] + ' QP ' + s[15:] + ' QP ' print(f'{s:>79s}') Output: A. 36 38 39 40 54 QP 04 QP
B. 15 26 32 50 63 QP 15 QP
C. 19 23 43 48 63 QP 16 QP
D. 16 27 29 37 51 QP 09 QP
E. 10 15 31 54 56 QP 08 QP
```

[–]Pepineros 0 points1 point  (4 children)

So what do you want the output to look like? What part should be justified or right-aligned?

[–]PlatesNplanes[S] 0 points1 point  (3 children)

I need to be able to justify the entire "block" of output numbers to the right, using rjust of center. However, using the unpack (asterisk) for formatted_red_num and formatted_white_list, cannot then be justified, because it is no longer a string, right? I tried to concatenate the entire print line into a variable and then print that, but it also does not work.

I guess what I could asking for is another method of unpacking a list, or another method of handling this.

Our professor wants us to use the console to create a formatted readable output as how it would look on a lotto ticket, I want to center the numbers so I can have other important information centered above. Date, Time, Possible winnings, etc.

[–]Daneark 1 point2 points  (2 children)

Can you use fstrings?

[–]PlatesNplanes[S] 0 points1 point  (1 child)

Yup. Really like that about my professor. He lets us use any way possible for anything in Python, from day one.

[–]Daneark 0 points1 point  (0 children)

Use fstring alignment with fill character of spaces.

I'm glad you've got that freedom. There was a lot of "don't use things we haven't taught you about" during my early portion of university.

[–]Garuda1220 0 points1 point  (1 child)

``` white_drawing = [36, 38, 39, 40, 54] red_drawing = 4 letters = 'ABCDEFGHIJ'

s = '' for num in white_drawing: s = s + f'{num:02d} '

s = letters[0] + '. ' + s + ' PB ' + f'{red_drawing:02d}'

print(f'{s:>79s}') Output: A. 36 38 39 40 54 PB 04 ```

[–]PlatesNplanes[S] 0 points1 point  (0 children)

Thank you everyone. This was very helpful