+ 1
Please help code gone wrong
http://www.sololearn.com/app/JUMP_LINK__&&__python__&&__JUMP_LINK/playground/cNY1qY6tqVys/
7 Respostas
+ 1
ok i see now. first thing is. you are storing your time values in a new list every time. Libraries are the prefered way of doing that. it stores a Key with a value pair. for example; [chapter_14 : 200] where the 200 stands for seconds. so ONE library holding all the chapters with their seconds. I suggest using only seconds and calculate the hours and minutes in a seperate function later. then you want to have Just one function that you feed all the chapters to. a function is able to take arguments so you don't have to use the global Keyword Here for updating the seconds variable. the idea is you're using a function to modify the value in your seconds variable. this way your function can Be used on More variables. Sorry for any spelling errors, this is hell typing on my phone.
+ 1
@bluntobjct Thank you i'll add in the times and make more dictionaries for other books. Thank you again
0
it would help if you describe what the program should do. what is the expected input the program asks for? I entered a string but it needed an integer. your code seems structured but is completely uncommented. Also, you Made a load of functions and they seem to behave the same, there should Be a better way to do that. Also it is not good to nest this many if statements. recursive functions might be a thing to Look up.
0
@bluntobjct Well yoy are supposed to enter the current chapter you are on, an int. Then it is supposed to add up all the time in the next chapters and output the minutes and seconds that i have to read
0
@bluntobjct Thanks! But what do you mean by having one function to feed all the chapters into? Sorry i'm not good at python.
0
@Michael Sorry, 'feed into' was a poor choice of words. when i get back from work i'll try and rewrite your code to show you what i Mean. I might not find the time though.
0
hey Michael, i rewrote your program and Made notes at the bottom. try it out with inputs 1, 2 or 3. please note i Made my own chapters with random time. read the notes and hopefully you'll Be able to understand. ask me if anything is unclear. the good news is, the program can now Be used for any new Book. link: http://www.sololearn.com/app/JUMP_LINK__&&__python__&&__JUMP_LINK/playground/c9lztUAo0Zpd