I have a list of tuples as shown:
lt = [(1,'a'),(1,'b'),(2,'a'),(3,'b'),(3,'c')]
Run Code Online (Sandbox Code Playgroud)
I want to make the numbers keys of a dictionary and have them point to a list. That list then holds all associations in the list of tuples. So in the list above, it would split into a dictionary as:
dict_lt:{
1:[a,b],
2:[a],
3:[b,c]
}
Run Code Online (Sandbox Code Playgroud)
Currently I use the dictionary's flexibility in automatically declaring new keys, which I then force point to an empty list. Then I fill that …
#include <stdio.h>
#define PREC 4
int main()
{
long l = 12;
printf("%PRECld", l);
}
Run Code Online (Sandbox Code Playgroud)
我将如何使用它PREC来定义所需的精度?即预期的产出是0012。目前正在印刷%PRECld。