如何將Python中的以下程序更改爲函數式樣?for循環與函數式編程風格的打印python
from itertools import permutations
for p in permutations(range(1, int(input()) + 1)):
print(*p, sep='')
我知道地圖,但
map(lambda p: print(*p, sep=''), permutations(range(1, int(input()) + 1)))
不會產生預期的輸出。
我想知道如果不重新定義for循環,是否可以這樣做。
你從中得到什麼好處? –
https://stackoverflow.com/a/20296780/2308683(和其他答案那裏) –
這是我的課程中的一個練習,並且不允許有 –