Python Lambda TypeError I don't know why.

Asked 2 years ago, Updated 2 years ago, 17 views

files = input().split()

print(list(lambda a : '{0:0>7}'.format(a) if len(a) == 5 else '{0:0>8}'.format(a), files))

When I type 4.png, I want to print it out as "004.png" Line 2 keeps getting an error below. I don't know what's wrong with Google it(Crying)

An exception has occurred. TypeError list expected at most 1 arguments, got 2

python

2022-09-21 17:44

1 Answers

list(map(lambda a : '{0:0>7}'.format(a) if a[-4] == '.' else '{0:0>8}'.format(a), files))

I have to write it like this. I'm asking and answering.


2022-09-21 17:44

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.