我有以下字典,我只需要打印带有奇数(1、3 ...)的字典。我将如何去做?
zen = {
1: 'Beautiful is better than ugly.',
2: 'Explicit is better than implicit.',
3: 'Simple is better than complex.',
4: 'Complex is better than complicated.',
5: 'Flat is better than nested.',
6: 'Sparse is better than dense.',
7: 'Readability counts.',
8: 'Special cases aren't special enough to the rules.',
9: 'Although practicality beats purity.',
10: 'Errors should never pass silently.'
}
Run Code Online (Sandbox Code Playgroud)
到目前为止,我有:
for c in zen:
print (c , zen[c][:])
Run Code Online (Sandbox Code Playgroud) python ×1