How to convert the out put we got from forloop back into a list?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How to convert the out put we got from forloop back into a list??

def n_numbers(number): lst =[1,2,3,4] for i in lst: print(i*number) print(n_numbers(4))

29th Apr 2020, 6:38 PM
Anish Tilloo
4 Answers
+ 1
RAJESH SAHU you didn't need to provide answer to person,that's not how they learn and I gave enough hint to make him dig deeper about append method and how list works ,I could have just provide the answer as well
29th Apr 2020, 6:54 PM
Abhay
Abhay - avatar
0
Initialise a empty list to some variable before for loop and in for loop after append the result i*number to it in case you didn't understand I will provide the answer but try first hopefully you are familiar with list methods
29th Apr 2020, 6:43 PM
Abhay
Abhay - avatar
0
new=[] for i in lst: new.append(i * number)
29th Apr 2020, 6:51 PM
ANJALI SAHU
- 1
Mention the language name in tags And also put the code link in description ,that will give better insights into what you have done and how we can help
29th Apr 2020, 6:39 PM
Abhay
Abhay - avatar