一行Python 打印沙漏

(臭显摆一下)

print("\n".join(list(map(lambda x:" "*x+"*"*(7-2*x),range(3)))+list(map(lambda x:" "*(7-x)+"*"*(7-2*(7-x)),range(4,8)))))

2 个评论

lambda表达式我都没看懂
lambda x:" "*x+"*"*(7-2*x) == def foo(x) { return " "*x+"*"*(7-2*x) }

map(lambda x:" "*x+"*"*(7-2*x),range(3)) == for i in range(3) { foo(i) }

要回复文章请先登录注册