+ 1
Ques: we have a list = ['my','name','is','ashish'] and give the result like this ['m', 'n', 'i', 'a'] without any loop.
This question asked in the one of my interview
5 Answers
- 1
def first_char(a,b,x=[]):
if b >= len(a)+b:
print(x)
print("task done")
else:
iteration = iter(a)
x.append(next(iteration)[0])
return first_char(a[1:],b+1,x)
def main():
first_char (['my','name','is','ashish'],b = 0)
main()
+ 2
Thats not how this works. If you don't know how to solve a problem, ask with your attempt. If you already know, then there's no need for a question
+ 2
print(list("mnia"))
+ 1
You might be using anonymous function but it also used loop internally.
Well bro share your answer now
0
This is the solution guys