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
Similar Kata:
Stats:
Created | Mar 26, 2021 |
Published | Mar 26, 2021 |
Warriors Trained | 826 |
Total Skips | 7 |
Total Code Submissions | 3340 |
Total Times Completed | 500 |
Python Completions | 500 |
Total Stars | 17 |
% of votes with a positive feedback rating | 87% of 126 |
Total "Very Satisfied" Votes | 101 |
Total "Somewhat Satisfied" Votes | 18 |
Total "Not Satisfied" Votes | 7 |
Total Rank Assessments | 36 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 8 kyu |