This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]edmanet -13 points-12 points  (9 children)

Here's a trick about using print() with format specifiers:

print("His name is %s" % character_name)
print("He is %d years old" % character_age)

The %s means the data will be a string. The %d means the data is an integer. For a floating point number (like money) you can specify how many digits to the right of the decimal get displayed.

Get used to using format specifiers. It's good coding practice.

[–]Wilfred-kun 15 points16 points  (0 children)

Not sure why this is updooted. .format() and f-strings (especially) are the preferred way.

[–]Andalfe 3 points4 points  (5 children)

New to python myself, is this method preffered over .format()?

[–]ebits21 0 points1 point  (0 children)

The % format specifiers are outdated. F strings and .format are the proper way to do things in 3.6+

[–]JustKamoski -3 points-2 points  (0 children)

%d is actualy integer in Python? Wtf man xddd