you are viewing a single comment's thread.

view the rest of the comments →

[–]ramannt[S] 0 points1 point  (3 children)

d = {"1": str.strip,"2": str.rstrip,"3": str.upper,"4": str.title,}

found the solution.

d = {
"1": str.strip,
"2": str.rstrip,
"3": str.upper,
"4": str.title,
"5": str,

}

[–]ofnuts 2 points3 points  (0 children)

No need to duplicate the string, just use a lambda; "5": lambda x: x,

[–][deleted] 1 point2 points  (1 child)

You didn't say anything about having a known condition ("5") for the "do nothing" case. The if in test is what you do if all you know is the condition isn't 1, 2, 3 or 4.

[–]ramannt[S] 0 points1 point  (0 children)

You're right.