You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This exercises is based on flatting a nested list.
My output result/Actual value (m_list) is exactly the same as expected value, but it shows me failed!
I found that the order of my list is different from the order of expected value and it causes the failed result.
I think you should fix it! while the ordering is depensing on "flatting the list method"
To perevent this error, you can ask about "sorting the m_list". so no matter the method, the results will be the same.
My Actual value is:
['good morning', 'Reach for Tomorrow', 'mariners song', 'music', 'instagram', 'On my Own', 'monster', 'Words dont come so easily', 'lead me right']
The Expected value is:
['good morning', 'music', 'instagram', 'On my Own', 'monster', 'Words dont come so easily', 'lead me right', 'Reach for Tomorrow', 'mariners song']
and my code is:
import copy
d = ['good morning', 'hello', 'chair', 'python', ['music', 'flowers', 'facebook', 'instagram', 'snapchat', ['On my Own', 'monster', 'Words dont come so easily', 'lead me right']], 'Stressed Out', 'Pauver Coeur', 'Reach for Tomorrow', 'mariners song', 'Wonder sleeps here']
def flatten(array1):
array2=[]
for l in array1:
for m in l:
array2.append(m)
return(array2)
m_list=[]
k=0
list1=copy.deepcopy(d)
while k==0:
k=1
list2=[]
for lv1 in list1:
if (type(lv1)==str) and ('m' in lv1):
m_list.append(lv1)
elif (type(lv1)!=str):
list2.append(lv1)
k=0
list1=flatten(list2)
print(m_list)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
This exercises is based on flatting a nested list.
My output result/Actual value (m_list) is exactly the same as expected value, but it shows me failed!
I found that the order of my list is different from the order of expected value and it causes the failed result.
I think you should fix it! while the ordering is depensing on "flatting the list method"
To perevent this error, you can ask about "sorting the m_list". so no matter the method, the results will be the same.
My Actual value is:
['good morning', 'Reach for Tomorrow', 'mariners song', 'music', 'instagram', 'On my Own', 'monster', 'Words dont come so easily', 'lead me right']
The Expected value is:
['good morning', 'music', 'instagram', 'On my Own', 'monster', 'Words dont come so easily', 'lead me right', 'Reach for Tomorrow', 'mariners song']
and my code is:
Beta Was this translation helpful? Give feedback.
All reactions