Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis+ 11
Why doesn't code work? Result: cold it sunny today
15 Respostas
+ 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.
+ 12
ŠŠ°ŃŠøŠ½Š°
The problem is the i = i + 1 is inside the if clause statement.
https://code.sololearn.com/cVMR35eMW8va/?ref=app
+ 5
ć Nicko12 ć ,thank you very much šš
+ 4
ć Nicko12 ć, ok, thank you š¤
+ 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))
+ 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 ...
+ 2
Ipang, I Need to select the last letter in a word and sort.
+ 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.
+ 2
Ipang ,
I C.
It used to show something like "Time out" previously. Maybe they broke something on back-end. lol.
+ 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
+ 2
Akgul Owmadowa , Rahmat don't spam.
+ 1
What is the sorting criteria?
Check indentation in while-loop maybe?
+ 1
š®š³Omkarš
Yes, previously an infinite loop gives timeout message. Maybe they did something in some updates dunno for sure š
- 2
Salam
- 3
Hi
How are you?