+ 4
What is the error?
I can't find my mistake help me to find my mistake https://code.sololearn.com/cxzyEdbQJBZr/?ref=app
9 ответов
+ 4
Thanks Russ for your kind help and also next time i keep things in mind while coding.🎉
+ 3
Its okay Russ Thank you for the correction you have made in this code. As i am student i want to ask you which book you prefer for to improvise the code.
If you assist me to improve my coding it would be a great help.
+ 3
Its okayRuss thank you again😊
+ 3
Thanks Code Crasher this is useful 😊
+ 2
There are a few issues with your code. Firstly, for loops do not require you to manually increment the iterator variable.
for i in range(5):
...
does not require you to put i = i + 1 inside. It increments automatically.
Secondly, the variable in your while loops only need to be altered at the end of each for loop, not with every iteration of it.
Thirdly, your if statement (line 33) was throwing an IndexError because you were referencing an index beyond its range.
Here is your amended code.
https://code.sololearn.com/cV0Y7paK2Qj2/?ref=app
+ 2
Coder Singh♋ Just a piece of advice for the future; it makes a huge difference if either your code is documented in order to help someone else reading it to understand what it's trying to achieve, or if you name your variables with a more-meaningful name than 'r' or 'e'.
The truth is that you would have gotten an answer here much, much quicker had you done either of these. It's only because I'm sitting here with no work to do that I had the time or inclination to try and pick apart your code and what each section was trying to do.
It all may look obvious to you, but for a fresh pair of eyes, trust me it looks like a random jumble.
Document and/or name variables properly. It's a very good habit to get into. 👍
Happy coding!
+ 2
Apologies Coder Singh♋ : when I saved my amended code, I didn't notice that it reset itself to your original code 🤦🏼♂️
Code updated now.
+ 2
Coder Singh♋ I've never taken any CS class nor have I used any books to learn. All my knowledge pretty much comes from SL and partaking in challenges and stuff. Sorry I can't help you in that respect.
If you need help in future with a problem, I'm happy to accept PMs 😉