6 kyu

Convert Lambda To Def

Description:

Convert Lambda To Def

in this kata, you will be given a string with a lambda function in it. Your task is to convert that lambda function to a def function, with the exact same variables, the exact same name, and the exact same function it does.

The function, like a normal def function should be returned on a separate line.

The output should be returned as a string.

Examples

given an input of:

"func = lambda a: a * 1"

The output expected would be:

"""
def func(a):
    return a * 1
"""

the code would be like so:

convert_lambda_to_def("func = lambda a: a * 1")
# the output should == "def func(a):\n    return a * 1"

you need to put 4 four spaces before the return part of your output.

variable numbers of spaces, positional/keyword arguments, or zero arguments will not be tested.

double parameters will not be tested

Happy Coding!

If you liked this, you can also check out the opposite of this kata: Convert Def To Lambda

Fundamentals
Strings
Regular Expressions

More By Author:

Check out these other kata created by The-Kingfisher

Stats:

CreatedMar 26, 2021
PublishedMar 26, 2021
Warriors Trained826
Total Skips7
Total Code Submissions3340
Total Times Completed500
Python Completions500
Total Stars17
% of votes with a positive feedback rating87% of 126
Total "Very Satisfied" Votes101
Total "Somewhat Satisfied" Votes18
Total "Not Satisfied" Votes7
Total Rank Assessments36
Average Assessed Rank
6 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • The-Kingfisher Avatar
  • ozichukwu Avatar
  • Wei-Ting Yang Avatar
Ad