0
Python Code explaination
CAN SOMEONE PLEASE EXPLAIN THIS CODE TO ME FULL THOROUGHLY, I DO GET It A LITTLE BUT IM STILL NOT SATISFIED WITH WHAT I GET. A VERY THOROUGH EXPLAINATION IS HIGHLY APPRECIATED. [ P.S I DONT KNOW WHY MY KEYBOARD IS WRITING UPPER CASE. SORRY HAHA P.S.S CAPS LOCK IS OFF ] https://code.sololearn.com/c62DmYh3jrpX/?ref=app
9 Answers
+ 5
Maybe copied from somewhere?
(In that case, you should put into your code where you've got it from!)
+ 4
R Raza this is actually simple but I'm not sure where your confusion is. Can you kind of explain what you know so we can fill in the gap of understanding.
The code works fine and this can be seen as advertising more than a true question.
+ 3
R Raza In the loop definition you say -1, range(99,0,-1). So it substracts every time 1 to your index beer_num for this reason it works. You don't need the new_num variable to work, it is redundant.
+ 2
BroFar thanks.
i do get the range and for functions, theyre not so hard to explain. what i fail to understand is that how the code actually works after the first else statement, thats when it starts to get confusing... Like; i get the first if statement and thats fine but how does the code compile the rest of it?
i didnt write the print() for the No. of beers left after 99 but the code somehow got it and kinda proceeded? How?
maybe ive a problem with the if/else understanding yet?
i still feel like i didnt explain what i wanted to but hope you get me, lol.
and no its not advertising :p
+ 2
HonFu Oh the code i wrote myself, (learned it from another place, thought to try it here on SoloLearn) but i dont seem to understand what i wrote. surprised with the results tbh. hahah
+ 2
R Raza It would work without the else part. What is the question? What did you want to achieve? Do you want to remove 2 beers in the same loop? Because it counts the same amount of beers when you substract 1 beer in the else part and then when is restarting the loop.
+ 1
GeraltdeRivia i want to understand how the loop restarts over with one less number of beer after every 3 lines eventhough i never used a line of code like âprint (new_num, word, âof beer on the wall)â
please help.
+ 1
Code Crasher wow thanks a lot man, such a readable code â€ïž... i canât appreciate enough. Now iâm getting a little more hang of it thanks to you simplifying it.
and yes, maybe i do need to study this code a little more. Thanks again