Unfold a list within a list in Python
Question
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
It will take less than 1 minute to register for lifetime. Bonus Tip - We don't send OTP to your email id Make Sure to use your own email id for free books and giveaways
Answers ( 3 )
Output=[]
for i in Input:
if type(Input) is ‘list’:
for value in i:
Output.append(value)
else:
Output.append(i)
Output
Output=[]
def checkType(a_list):
for element in a_list:
if isinstance(element, int):
Output.append(element)
if isinstance(element, list):
for i in element:
Output.append(i)
return Output
Input = [1,2,3,5,[45,56,67],4]
print(checkType(Input))
new_list = []
for i in range(len(original_list)):
if type(original_list[i]) != list:
updated.append(original_list[i])
else:
for j in range(0,len(original_list[i])):
updated.append(original_list[i][j])
print(new_list)