# Quick questions about Python Dictionary

Asked 2 weeks ago, Updated 2 weeks ago, 1 views

This is part of the Aegis Publishing Algorithm book. I'm reviewing it again, but I don't understand it no matter how much I look at it. There are several questions in related communities, but no one has answered...

``````def card_conv(x: int, r: int) -> str:
"""Returns a string representing the number after converting an integer x to r"""

d = '' # string after conversion
dchar = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
n = len(str(x)) # Digits before conversion

print(f'{r:2} | {x:{n}d}') # Dictionary?....
while x > 0:
print(' +' + (n + 2) * '-') # (to make the number of --- according to the number of digits when expressing the expression look neat)
if x // r:
print(f'{r:2} | {x // r:{n}d} … {x % r}')
else:
print(f'     {x // r:{n}d} … {x % r}')
d+=dchar[x %r] #Take out the corresponding character and combine it
x //= r

returned[::-1] #Return in reverse order
``````

medium the eighth row In ```print(f'{r:2} | {x:{n}d}), is it correct that {r:2} means {r:2} and set the value to 2? If so, I wonder which syntax you need this dictionary for I don't even know what d means in {x:{n}d}```

``` python dictionary 2022-09-20 13:32 ```
``` ```
``` 1 Answers This is not a dictionary. It's a completely unrelated grammar.Grammar related to string formatting called f-string.f"{r:2}" means to create a string so that the value of the variable r is two spaces (2).Search Python f-string to learn how to use it. It's very convenient, so take this opportunity to practice well.https://docs.python.org/ko/3/reference/lexical_analysis.html#f-strings 2022-09-20 13:32 If you have any answers or tips ```
``` Popular Tags python x 4520 android x 1589 java x 1455 javascript x 1363 c x 881 php x 682 html x 629 swift x 586 ios x 538 mysql x 397 Popular Questions 21 GDB gets version error when attempting to debug with the Presense SDK (IDE) 10 ipynb code content search tool recommendation 15 If parameter X determines the return value Y, which function name would be the most appropriate? 9 How do I add index rows in Python beginner Pandas? 14 I want to apply all the files in the folder as a for statement. ```
``` window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'UA-109404861-1'); //아이콘 설정 feather.replace({color: '#ffc107', width: 12, height: 12}); //oembed document.querySelectorAll('oembed[url]').forEach(element => { const anchor = document.createElement('a'); anchor.setAttribute('href', element.getAttribute('url')); anchor.className = 'embedly-card'; element.appendChild(anchor); }); \$(document).ready(function () { // 스크랩 \$('#q_scrap').click(function () { \$.post("/scrap", {'qid': "797"}, function (data) { }); \$('#q_scrap').popover('show'); setTimeout(function () { \$('#q_scrap').popover('hide'); }, 1000); }); //질문 추천 \$('#q_score').click(function () { if (\$(this).attr("data-on") == "off") { \$.post("/score_q", {'qid': "797"}, function (data) { if (data == "OK") { var score = parseInt(\$('#q_score_num').text()) + 1; \$('#q_score_num').html(score); \$(this).attr("data-on", "on"); } }); } }); //신고 \$('#q_spam').click(function () { \$.post("/spam", {'qid' : "797"}, function (data) { }); \$('#q_spam').popover('show'); setTimeout(function () { \$('#q_spam').popover('hide'); }, 1000); }); //수정 \$('#q_edit').click(function () { \$(location).attr('href', "/question/edit/797"); }); //삭제 \$('#q_del').click(function () { \$(location).attr('href', "/question/delete/797"); }); // 답글 추가 \$('#a_add').click(function () { \$(location).attr('href', "/answer/add/797"); }); // 답글 수정 \$('.a_edit').click(function () { var aid = \$(this).attr("data-aid"); \$(location).attr('href', "/answer/edit/" + aid); }); //답글 삭제 \$('.a_del').click(function () { if (!confirm('Do you want to delete this answer?')) { return false; } var aid = \$(this).attr("data-aid"); \$(location).attr('href', "/answer/delete/" + aid); }); //답글 추천 \$('.a_score').click(function () { if (\$(this).attr("data-on") == "off") { \$(this).attr("data-on", "on"); var aid = \$(this).attr('data-aid'); \$.post("/score_a", {'aid': aid}, function (data) { if (data == "OK") { var score = parseInt(\$('#a_score_'+aid).text()) + 1; \$('#a_score_'+aid).html(score); } }); } }); }); © 2022 pinfo. All rights reserved. ```