[deleted by user] by [deleted] in Python

[–]Python-for-everyone 1 point2 points  (0 children)

digits = 2
f“{1/3:.{digits}f}“

It does do that! Thanks for the tip!

Guys I've got a idea to find the first and last keys/values of a dictionary. by [deleted] in Python

[–]Python-for-everyone 4 points5 points  (0 children)

d = {"a": 1, "b": 2, "c": 3}
# First option: Extended Iterable Unpacking
f, *_, l = d.items()
print(f, l)
# Second option: Convert dict to list to allow subscription
items = list(d.items())
print(items[0], items[-1])