Why doesn't code work? Result: cold it sunny today | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 11

Why doesn't code work? Result: cold it sunny today

https://code.sololearn.com/chDQx4UJN3VQ/?ref=app

12th Dec 2020, 10:34 AM
ะœะฐั€ะธะฝะฐ
ะœะฐั€ะธะฝะฐ - avatar
15 Answers
+ 13
ะœะฐั€ะธะฝะฐ , the issue is the incrementation of "i". It is in if clause, so it will not be incremented in all cases. Put it one level to the left on same position as "if". BTW, indentation width is not as recommended like 4 spaces.
12th Dec 2020, 10:59 AM
Lothar
Lothar - avatar
+ 12
ะœะฐั€ะธะฝะฐ The problem is the i = i + 1 is inside the if clause statement. https://code.sololearn.com/cVMR35eMW8va/?ref=app
12th Dec 2020, 10:56 AM
noteve
noteve - avatar
+ 5
ใ€Š Nicko12 ใ€‹ ,thank you very much ๐Ÿ™๐Ÿ™
12th Dec 2020, 11:02 AM
ะœะฐั€ะธะฝะฐ
ะœะฐั€ะธะฝะฐ - avatar
+ 4
ใ€Š Nicko12 ใ€‹, ok, thank you ๐Ÿค—
12th Dec 2020, 11:07 AM
ะœะฐั€ะธะฝะฐ
ะœะฐั€ะธะฝะฐ - avatar
+ 4
ะœะฐั€ะธะฝะฐ Your Code is fixed This is just an another way of doing this :) text = " it is cold and sunny outside today" textList = text.split() newList = [] for x in textList: if textList.index(x) % 2 == 0: newList.append(x) newList = sorted(newList ,key = lambda x : x[-1]) print(" ".join(newList))
13th Dec 2020, 11:38 PM
Mahad Ahmed
Mahad Ahmed - avatar
+ 3
ะœะฐั€ะธะฝะฐ Look at edit by Nicko12 ๐Ÿ‡ฎ๐Ÿ‡ณOmkar๐Ÿ•‰ Being unedited it shows "No output" seems the while-loop body needs indentation fix, it is infinite as it is ...
12th Dec 2020, 10:59 AM
Ipang
+ 2
Ipang, I Need to select the last letter in a word and sort.
12th Dec 2020, 10:54 AM
ะœะฐั€ะธะฝะฐ
ะœะฐั€ะธะฝะฐ - avatar
+ 2
Ipang , What output are you getting from this code ๐Ÿง? For me, it's showing no output. I was expecting at least first 3 lines to run properly.
12th Dec 2020, 10:55 AM
๐Ÿ‡ฎ๐Ÿ‡ณOmkar๐Ÿ•‰
๐Ÿ‡ฎ๐Ÿ‡ณOmkar๐Ÿ•‰ - avatar
+ 2
Ipang , I C. It used to show something like "Time out" previously. Maybe they broke something on back-end. lol.
12th Dec 2020, 11:01 AM
๐Ÿ‡ฎ๐Ÿ‡ณOmkar๐Ÿ•‰
๐Ÿ‡ฎ๐Ÿ‡ณOmkar๐Ÿ•‰ - avatar
+ 2
ะœะฐั€ะธะฝะฐ You're Welcome! And BTW I know this is off topic, but this is about indentions. Be careful with the indention in SoloLearn, sometimes they are not alligned even with the SAME number of SPACES. And when it happens, it causes an error. Try delete all spaces then space again, that way it will get alligned. Just additional Info
12th Dec 2020, 11:06 AM
noteve
noteve - avatar
+ 2
Akgul Owmadowa , Rahmat don't spam.
14th Dec 2020, 7:29 AM
Sonic
Sonic - avatar
+ 1
What is the sorting criteria? Check indentation in while-loop maybe?
12th Dec 2020, 10:50 AM
Ipang
+ 1
๐Ÿ‡ฎ๐Ÿ‡ณOmkar๐Ÿ•‰ Yes, previously an infinite loop gives timeout message. Maybe they did something in some updates dunno for sure ๐Ÿ˜
12th Dec 2020, 11:04 AM
Ipang
- 2
Salam
13th Dec 2020, 8:13 AM
Akgul Owmadowa
- 3
Hi How are you?
12th Dec 2020, 4:05 PM
Rahmat
Rahmat - avatar