27th Sep 2023, 5:02 AM
Lullaby - avatar
7 Answers
+ 5
Lullaby Don't use bad language like code name on learning platform
27th Sep 2023, 3:57 PM
A͢J - avatar
+ 5
Lullaby , Wong Hei Ming , here is what the python docs are saying to `else clause` in a `for loop` or in a `while loop`: > https://docs.python.org/3/tutorial/controlflow.html#break-and-continue-statements-and-else-clauses-on-loops
27th Sep 2023, 3:50 PM
Lothar - avatar
+ 3
Start with the error your code gives you when you run it. It is pointing you in the direction you need to look first. Hint: comparison operators Don't forget, Google is your friend. Learning to code has sharpened my googling skills.
27th Sep 2023, 5:31 AM
Aaron Lee
Aaron Lee - avatar
+ 3
Although there are mistakes in the code I learned something new. With the original code, “while” and “else” are in the same level. After fixing other errors and run the code, it prints “Done”, which surprised me. I didn’t know “while” and “else” can put on the same level. It almost the same as “if…else…”, but “if” is replaced by “while”. And I found w3schools does have an example of this usage!
27th Sep 2023, 1:06 PM
Wong Hei Ming
Wong Hei Ming - avatar
+ 1
i=0 while i <= 10: i=i+1 if i==5: continue print(i) else: print ('Done') # 1. comparison operator <= # 2. no colon after while statement # 3. indentation error - print(i) # 4. Relocate print function to allow continue to skip the printing when i=5 # 5. Using an obscenity as a code name is your biggest mistake & may get you banned from this site
27th Sep 2023, 9:59 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 1
Add a second = to the i = 10 like this i == 10
28th Sep 2023, 5:04 PM
Timmothy Rain
Timmothy Rain - avatar
Aj coming in clutch totally helping solve the problem
29th Sep 2023, 3:25 AM
Sickfic - avatar