# [closed] Homework 2 Question 6

 0 UPDATE Please see additional comment below original question. Hello, I am having a bit of trouble coming up with the correct answer on number 6. Code in general is completely new to me and these courses, where as they are done well, the pace is very quick. I spent over ten hours straight on Unit 2 and homework the other day, and I'm finally coming back to it to try again. I've finally gotten further in the homework, and I know I can get this if I just keep at it. On problem 6 of the homework, I feel like I have a valid code that should work. It's going to be a bit difficult to talk about since, I can't post code or any potential answers (though obviously my 'answer' is wrong since it isn't working). Basically I combined knowledge from Unit 2.15 and 2.25. That's the best way I can explain it without posting my code. However, when I try to print find_last('aaaa','a'), I don't get any result. I don't even get an error message. I simply get an orange pop-up box at the top that says "Try again!" What does this mean? Without any kind of code error and/or output, I don't really have anything to go off of where to correct my code. Any assistance would be greatly appreciated. I really want to get this done before tomorrow night. Thank you, Shay asked 06 Mar '12, 04:17 Shay 90●1●2●9 accept rate: 0% UPDATE I kind of had this going in another thread, but I didn't want to deter that thread from its original post about this website. http://people.csail.mit.edu/pgbovine/python/tutor.html Ok, so with this site, I was able to find out that I have an infinite loop. However, based on the information it's showing me in each step, I don't understand why my code is not working. Without posting any exact code since it's homework... I have the following. def find_last(): variable1 variable2 while : new variable1 return variable2 print find_last()  Based on the information provided in the website, my variable1 is changing correctly as I intended it. The formula for variable2 contains variable1, however the value for variable2 does not seem to be changing. If variable1 is changing each time it goes through the loop, shouldn't variable2 automatically be modified as well? Any advice or explanation? (06 Mar '12, 07:27) Shay

### The question has been closed for the following reason "bdiddy was able to assist in the flaw of my formula on another thread. Thanks everyone! :)" by Shay 06 Mar '12, 08:14

 0 No result, no feedback.. it sounds like you may have your indents off. Is your print statement within the function? (it shouldn't be, but it can be if your indents are off, etc). Also, it's possible that you have an infinite loop. Make sure you terminate your code for all possible inputs. Do you only use the udacity interpreter, or do you have a local one? answered 06 Mar '12, 04:19 Rob Barnes-3 ♦ 19.1k●10●68●205 I double-checked my indents. What I have without posting the actual code is the following: def find_last(): value1 value2 while statement: new value1 statement return value2 print find_last()  (06 Mar '12, 04:24) Shay Sorry, I seem to have missed the last part of that. The answer to the second question is I use the udacity interpreter. I couldn't remember where I saw it in unit 1 with the information on where to download. I ended up downloading 3.2, but not sure if that's the correct one. (06 Mar '12, 04:31) Shay Thanks to this website http://people.csail.mit.edu/pgbovine/python/tutor.html that someone posted just recently, I was able to determine it's due to an infinite loop. So now I just have to figure out why it's an infinite loop and hopefully find a way to correct it. (06 Mar '12, 06:18) Shay
 0 Try again , wont be popped up in Homeworks .. For no output , try doing a dry run ... check variable by variable ...you should get the issue with dry run!! answered 06 Mar '12, 04:21 Kumar Abhishek 653●9●13●34

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "Title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported

×15,217
×1,718
×168
×117
×74
×17